• Resolved bvk69varghese

    (@bvk69varghese)


    Hi,

    For my client’s requirement I need to hide the European shipping methods. I have removed the European shipping zone through the admin section. In front end I need to show a custom message if there is no shipping methods allocated for the user if he set his shipping country as European country. For that I have created a custom message for the top error message in checkout page like below. This will trigger when the user clicks on “Place order” button.

    add_filter( 'gettext', 'wbsuk_no_shipping_options_top', 10, 3 );
    	function wbsuk_no_shipping_options_top( $translated, $original, $domain ) {
    		if ( $translated == 'No shipping method has been selected.    Please double check your address, or contact us if you need any help.' ) {
    		$translated = 'TEST MESSAGE';
    		}
    		return $translated;
    	}

    But I am not getting the user shipping country. I have written a code in my plugin file and getting error if I use any of these.

    if (strstr($current_rel_uri ,”/checkout”) != ”) {
    $country = WC()->customer->get_shipping_country();
    OR
    global $woocommerce;
    $woocommerce->customer->get_shipping_country();
    }

    How to get the checkout user’s shipping country here? Please help me. Thanks.

    • This topic was modified 3 years, 5 months ago by bvk69varghese.

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Shaun Kuschel a11n

    (@shaunkuschel)

    Automattic Happiness Engineer

    Hey @bvk69varghese,

    I’d take a look at this article, as you could do something similar and just add all the 2 letter country codes for the European countries that should see the custom message.

    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Since it’s been a while since we last heard back from you, I’m going to mark this thread resolved.

    Hopefully, you were able to find a solution to your problem! If you have further questions, please feel free to open a new topic.

    Cheers! ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Woocommerce Cart Shipping Country’ is closed to new replies.