1

How would I allow my customers to choose their ship to country at any time in the site.

I thought I could do so with this example code but the checkout still defaults to the stores default values (If not logged in, still as guest)

$shippingAddress = Mage::getModel('checkout/cart')->getQuote()->getShippingAddress();
$shippingAddress->setCountryId('GB')->save();
// Great Britain as an example!

The goal is to not have to create a store for every country and to show the customers that we can ship to any country.

The customer will choose from a country select page and then the site would remember the ship to at checkout.

Any guidance would be appreciated.

0

You can try to set it in session:

Mage::getSingleton('checkout/session')->setCountryId('GB');

and then to change in app/code/core/Mage/Checkout/Block/Onepage/Abstract.php -> public function getCountryHtmlSelect($type) this code:

if (is_null($countryId)) {
    $countryId = Mage::helper('core')->getDefaultCountry();
}

with this:

if (is_null($countryId)) {
    if (Mage::getSingleton('checkout/session')->hasCountryId()) {
        $countryId = Mage::getSingleton('checkout/session')->getCountryId();
    } else {
        $countryId = Mage::helper('core')->getDefaultCountry();
    }
}
  • Seems to work! thanks, exactly what I needed. – Kevin Chatel Nov 27 '14 at 15:01

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.