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


  • I have updated my code to resolve 1 issue when customer is logged in. – Sarfaraz bheda Jul 11 '18 at 12:42
  • Regarding saved address, you can add dependency of 'Magento_Customer/js/model/customer', and get customer current details. – Sarfaraz bheda Jul 11 '18 at 12:43
  • To get shipping address information you can add dependency of Magento_Checkout/js/model/quote magento.stackexchange.com/questions/148788/… – Sarfaraz bheda Jul 11 '18 at 12:47
  • did you resolve the issue. can you post the answer if you did? Thanks – Kris Wen Sep 20 at 0:39

Include quote js like


in custom js. And try

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

it will give you country ID

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.