Get shipping country during cart view – WooCommerce

I want to get the chosen shipping country when on the cart / checkout (so before the order is placed).
This is to determine if an extra fee (above the normal shipping costs) must be added.

How can i get the chosen country for this function?
I use it in an if-function (in this example for the country ‘Belgium’):

Read More
 ` elseif ($total >= $min_order and $chosen_shippingcountry = 'BE') {$fees = 10;}`

Can anyone help?

Thanks!

Regards,
Cedric

Related posts

Leave a Reply

1 comment

  1. If I am not wrong, you are looking for the code to get shipping country set on WooCommerce cart / checkout page. Below code is tested till WooCommerce 2.4.

    Method #1:

    global $woocommerce;
    $woocommerce->customer->get_shipping_country()
    

    Method #2

    WC()->customer->get_shipping_country()
    

    Note that there are major changes on shipping side from WooCommerce 2.6. But from the GitHub reference, it should work.