cancel
Showing results for 
Search instead for 
Did you mean: 

Get country id in magento one page checkout after shipping method chosen

SOLVED

Get country id in magento one page checkout after shipping method chosen

Hi there

 

I am trying to get country ID in magento template files in the one page checkout... after the shipping method is chosen.

 

The issue that I am getting is that the country actually showing reflects the billing address, and not the shipping address when shipping address is different.

 

This is what I'm using in the template:

 

this->getQuote()->getShippingAddress()->getCountryId();

 

I have also tried this with the same result:

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

Thanks

M

2 REPLIES

Re: Get country id in magento one page checkout after shipping method chosen

Try with below solutions,

$checkout = Mage::getSingleton('checkout/session')->getQuote();
$getShippingAddress = $checkout->getShippingAddress();
var_dump($getShippingAddress);

You can also try with,

$getCountry = $this->getQuote()->getShippingAddress()->getCountry();

 

If Issue Solved, Click Kudos/Accept As solutions.

Re: Get country id in magento one page checkout after shipping method chosen

Thanks for your reply Rakesh!

 

This is on the one page checkout, and I now realize that I have been running these functions outside of where the ajax content is inserted. I think this should work, provided that the code is run in the template that is inserted into the one page checkout tab via ajax (because otherwise, the code is run when the page is loaded and before the customer changes their shipping address).