Magento – Magento 2 checkout page how to get country_id from selected shipping addresses

checkoutjquerymagento2shipping

How to get country id/country name from selected shipping address in the checkout page.

lets assume if the customer has multiple shipping addresses,
based on the shipping address choose, if country name is not United States we want to display some Text message on the top. (International Custom Duties……..)
enter image description here

for this i have followed @Sarfaraz bheda answer for creating hook.js

Magento2 – How to trigger onchange event on Country/region in Shipping Address

thanks

Best Answer

Include quote js like

    define([
        'Magento_Checkout/js/model/quote'
    ])

in custom js. And try

    var countryId = quote.shippingAddress().countryId;
    var country = countryData()[countryId].name;

it will give you country ID

Related Topic