PHP Notice: get_shipping_postcode was called incorrectly.
-
Hi,
I’m trying to add a shipping cost surcharge for particular suburbs. I’m using the following code, and functionally it works perfectly.
Unfortunately, it’s throwing the following PHP Notice:
get_shipping_postcode was called incorrectly. Customer properties should not be accessed directly.
add_action( 'woocommerce_cart_calculate_fees', 'outer_metro_add_cart_fee' ); function outer_metro_add_cart_fee() { $outermetro = array('5250','5251','5114'); if( in_array( WC()->customer->get_shipping_postcode, $outermetro ) ) { $surcharge = 3; WC()->cart->add_fee( __('Outer Metro Delivery', 'woocommerce'), $surcharge ); } }
Can anyone explain how I can get the shipping postcode from the checkout page without accessing it directly?
Thanks!
Viewing 3 replies - 1 through 3 (of 3 total)
Viewing 3 replies - 1 through 3 (of 3 total)
- The topic ‘PHP Notice: get_shipping_postcode was called incorrectly.’ is closed to new replies.