From 72eeaca45a16d7b2d5f5785e1323909feb47b68d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Sch=C3=A4fer?= Date: Mon, 2 Dec 2019 12:22:33 +0100 Subject: [PATCH 1/2] Fixed country switcher for existing quote country --- app/code/community/IntegerNet/Autoshipping/Model/Observer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/code/community/IntegerNet/Autoshipping/Model/Observer.php b/app/code/community/IntegerNet/Autoshipping/Model/Observer.php index 481b562..32ba6fd 100644 --- a/app/code/community/IntegerNet/Autoshipping/Model/Observer.php +++ b/app/code/community/IntegerNet/Autoshipping/Model/Observer.php @@ -40,7 +40,8 @@ public function prepareShippingAddress(Varien_Event_Observer $observer) } $shippingAddress = $quote->getShippingAddress(); - if (!$shippingAddress->getCountryId()) { + if (!$shippingAddress->getCountryId() + || ($country !== Mage::getStoreConfig('autoshipping/settings/country_id'))) { $shippingAddress->setCountryId($country); } From 320da295e2221f6c22eaa21e72e2584d0a381a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ole=20Sch=C3=A4fer?= Date: Mon, 12 Apr 2021 15:23:52 +0200 Subject: [PATCH 2/2] Only update country in cart --- .../community/IntegerNet/Autoshipping/Model/Observer.php | 5 ++++- .../Autoshipping/controllers/CountryController.php | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/app/code/community/IntegerNet/Autoshipping/Model/Observer.php b/app/code/community/IntegerNet/Autoshipping/Model/Observer.php index a1b26ee..e4bb6ac 100644 --- a/app/code/community/IntegerNet/Autoshipping/Model/Observer.php +++ b/app/code/community/IntegerNet/Autoshipping/Model/Observer.php @@ -40,13 +40,16 @@ public function prepareShippingAddress(Varien_Event_Observer $observer) } $shippingAddress = $quote->getShippingAddress(); - $shippingAddress->setCountryId($country); + if ($this->_getCoreSession()->getCountryIsManuallyChangedInCart() || !$shippingAddress->getCountryId()) { + $shippingAddress->setCountryId($country); + } if (!$shippingAddress->getFreeMethodWeight()) { $shippingAddress->setFreeMethodWeight($shippingAddress->getWeight()); } $this->_methodManuallyChanged = $this->_isMethodManuallyChanged($shippingAddress); + $this->_getCoreSession()->setCountryIsManuallyChangedInCart(false); } /** * Set shipping method diff --git a/app/code/community/IntegerNet/Autoshipping/controllers/CountryController.php b/app/code/community/IntegerNet/Autoshipping/controllers/CountryController.php index 6857daa..878a635 100644 --- a/app/code/community/IntegerNet/Autoshipping/controllers/CountryController.php +++ b/app/code/community/IntegerNet/Autoshipping/controllers/CountryController.php @@ -13,7 +13,7 @@ class IntegerNet_Autoshipping_CountryController extends Mage_Core_Controller_Fro public function selectAction() { $countryId = $this->getRequest()->getParam('country_id'); - Mage::getSingleton('core/session')->setAutoShippingCountry($countryId); + Mage::getSingleton('core/session')->setAutoShippingCountry($countryId)->setCountryIsManuallyChangedInCart(true); $this->_redirectReferer(); } -} \ No newline at end of file +}