0

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()
  • Cay please check with : Mage::getSingleton('checkout/type_onepage')->getQuote()->getShippingAddress() ->getCountryId(); – Nikunj Vadariya May 23 '18 at 11:19
  • I discovered my issue. The above lines do in fact work, the issue was that I was running them in a template file which loaded at the very start of the onepage checkout. Accordingly, no PHP ran after a user selects the shipping address. The solution was to run the PHP in template files which are inserted into the page via Ajax, as they will be able to access the updated shipping address. – JimmyTudeski May 24 '18 at 22:57
  • so my comment solve your issue? – Nikunj Vadariya May 25 '18 at 4:11
  • No, the solution to the issue was using the correct template file. The code itself was fine. – JimmyTudeski May 28 '18 at 2:35

Your Answer

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

Browse other questions tagged or ask your own question.