Woocommerce get current shipping zone

I create a custom shipping method.

In the calculate_shipping function i want to set the price of my shipping method based on the shipping zone:

If shipping zone is ‘Zone 1’ set price to 15
else set price to 20

So i want to know, how can i get the current shipping zone ?

I already try to see this doc: https://docs.woocommerce.com/wc-apidocs/class-WC_Shipping_Zone.html
Maybe i don’t understand…

public function calculate_shipping( $package=Array()) {
            global $woocommerce;



            // CONDITIONAL CHECK 

                // OPEN HOUR
                if($current_hour >= $start_hour &&  $current_hour <= $end_hour){

                // price PER ZONE
                $zone=""; // need to know how to get zone name or zone id
                if($zone=='Zone 1' && $cart_total>='60'){
                    $cost = 6;
                }elseif($zone=='Zone 2' && $cart_total>='120'){
                    $cost = 8;
                }elseif($zone=='Zone 3' && $cart_total>='180'){
                    $cost = 9;
                    $cost = 0;

                if($is_open==true && $min_order==true){

            $rate = array(
                'id' => $this->id,
                'label' => 'Livraison Express T '.wc_get_shipping_zone().' T',
                'cost' => $cost,

            // Register the rate
                $this->add_rate( $rate );

Read more here: Woocommerce get current shipping zone

Leave a Reply

Your email address will not be published. Required fields are marked *