From 886ab283deca41bed07f0095291ef1627b832f98 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Fri, 13 Apr 2012 08:22:27 +0000 Subject: [PATCH] [-] FO : #PSFV-815 - Fix bug on the cart with carrier on updating the country of the address git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14624 b9a71923-0436-4b27-9f14-aed3839534dd --- controllers/front/AddressController.php | 40 +++++++++++-------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/controllers/front/AddressController.php b/controllers/front/AddressController.php index bbcf294aa..8e6069725 100644 --- a/controllers/front/AddressController.php +++ b/controllers/front/AddressController.php @@ -201,25 +201,7 @@ class AddressControllerCore extends FrontController if (Customer::customerHasAddress($this->context->customer->id, (int)$address_old->id)) { if ($address_old->isUsed()) - { $address_old->delete(); - if (!Tools::isSubmit('ajax')) - { - $to_update = false; - if ($this->context->cart->id_address_invoice == $address_old->id) - { - $to_update = true; - $this->context->cart->id_address_invoice = 0; - } - if ($this->context->cart->id_address_delivery == $address_old->id) - { - $to_update = true; - $this->context->cart->id_address_delivery = 0; - } - if ($to_update) - $this->context->cart->update(); - } - } else { $address->id = (int)($address_old->id); @@ -231,12 +213,26 @@ class AddressControllerCore extends FrontController // Save address if ($result = $address->save()) { - // In order to select this new address : order-address.tpl - if ((bool)Tools::getValue('select_address', false) || ($this->ajax && Tools::getValue('type') == 'invoice')) + // Update id address of the current cart if necessary + if ($address_old->isUsed()) { - // This new adress is for invoice_adress, select it - $this->context->cart->id_address_invoice = (int)$address->id; + if ($this->context->cart->id_address_invoice == $address_old->id) + { + $to_update = true; + $this->context->cart->id_address_invoice = (int)$address->id; + } + if ($this->context->cart->id_address_delivery == $address_old->id) + { + $to_update = true; + $this->context->cart->id_address_delivery = (int)$address->id; + } $this->context->cart->update(); + + $sql = 'UPDATE `'._DB_PREFIX_.'cart_product` + SET `id_address_delivery` = '.(int)$address->id.' + WHERE `id_cart` = '.(int)$this->context->cart->id.' + AND `id_address_delivery` = '.(int)$address_old->id; + Db::getInstance()->execute($sql); } if ($this->ajax)