0

How to get requested shipping country id of checkout/cart/shipping.phtml on cart item list page code/core/Mage/CatalogInventory/Model/Stock/item.php?

1 Answer 1

3

The country ID is saved in the quotes shipping address. Check the CartController estimatePostAction method, Here the post for shipping estimation is handled.

Try this

$country = Mage::getSingleton('checkout/cart')->getQuote()
             ->getShippingAddress()
             ->getCountryId();
6
  • Its correct method to get country ID but its very very slow .... any alternative way to get it.
    – Sandesh
    Dec 26, 2013 at 7:15
  • 1
    unfortunately this is the only way to get the data from the quote object. You might be able to cut some response time by using Mage::getSingleton('checkout/session') directly but it won't be much Dec 26, 2013 at 8:31
  • is this country quote value store in database somewhere?
    – Sandesh
    Dec 26, 2013 at 9:21
  • yes in the sales address table Dec 26, 2013 at 10:31
  • What I did $quoteid= $_SESSION['core']['visitor_data']['quote_id']; $resource = Mage::getSingleton('core/resource'); $readConnection = $resource->getConnection('core_read'); $table = $resource->getTableName('sales/quote_address'); $query = 'SELECT country_id FROM '. $table.' WHERE quote_id = '. (int)$quoteid.' AND address_type = "shipping" ORDER BY updated_at DESC LIMIT 1'; $requestcontry = $readConnection->fetchOne($query); Is $requestcontry will be correct one always?
    – Sandesh
    Dec 26, 2013 at 10:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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