2

I try to set the country from my custom cart controller with the following function:

public function setCountryAction()
{
    $country = (string) $this->getRequest()->getParam('country');
    $quote = Mage::getSingleton('checkout/session')->getQuote();

    $quote->getBillingAddress()->setCountryId($country);
    $quote->getShippingAddress()->setCountryId($country);
    $quote->save();

    // print $quote->getBillingAddress()->getCountryId();
}

The print at the end of the function contains the expected result but unfortunately the country is not actually saved to the quote.

When I change the country from the checkout, go back to the cart and do the action again, strangely enough it works perfectly.

So the problem only exists with a new, empty session.

1

Instead of $quote->save(); or before it try

$quote->getBillingAddress()->save();
$quote->getShippingAddress()->save();
  • Hi, I tried but this is unfortunately not working. – Michael Jul 23 '15 at 9:13
1

Finally found! This issue has to do with the 'Default country' option in the OneStepCheckout extension.

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.