php - Woocommerce: get the shiping postal code to calculate shipping cost -
i'm developing new shipping method calculates rate based on bundle weight, volume , customers zip code... ive had no problem retrieving cart info on calculate_shipping function, when seek retrieve zip code client seems homecoming empty value. how can retrieve info on runtime in order calculate final cost?
public function calculate_shipping( $package ) { global $woocommerce; $items = $woocommerce->cart->get_cart(); $cliente = $woocommerce->customer; $peso = $woocommerce->cart->cart_contents_weight; $customer_postcode = $woocommerce->customer->get_shipping_postcode(); }
solved:
$customer_postcode = get_user_meta( get_current_user_id(), 'shipping_postcode', true );
global $woocommerce; $customer = new wc_customer(); $woocommerce->customer->get_shipping_postcode();
php wordpress woocommerce shipping
No comments:
Post a Comment