1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
|
add_action('woocommerce_after_calculate_totals', 'cwpai_get_customer_postcode');
/**
* Get customer postcode after shipping calculation
*/
function cwpai_get_customer_postcode() {
// Get the customer's shipping address object
$customer_shipping_address = WC()->customer->get_shipping_address();
// Check if the customer has a shipping postcode
if (isset($customer_shipping_address['postcode'])) {
// Store the customer's shipping postcode in a global variable
global $cwpai_customer_postcode;
$cwpai_customer_postcode = $customer_shipping_address['postcode'];
}
} |
Partager