Magento : How to get countryID from selected / entered shipping address

Kim Herman picture Kim Herman · Sep 29, 2012 · Viewed 16.1k times · Source

I'm trying to hide some text / code based in the shipping_method.phtml based on whether the country of the selected or entered shipping address is France or not in .

The only code I found was

Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress()->getCountryId()

But all this does is return the countryID of my default address in the address book. So the code works when the address is already in the address book, but not if the customer decides he/she want to send it to a new address.

So I need a way to access the selected / entered CountryID in php/javascript (should be stored in the session somewhere, because it's shown in the progress sidebar).

Please note that I'm using standard onepage checkout in magento CE 1.7.0.2.

Answer

Afsal picture Afsal · Oct 15, 2012

You can try this code $this->getQuote()->getShippingAddress()->getCountry() to get country id.