[-] FO : #PSFV-815 - Moving an SQL request on the controller to the model
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14762 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -193,6 +193,35 @@ class CartCore extends ObjectModel
|
|||||||
|
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Update the address id of the cart
|
||||||
|
*
|
||||||
|
* @param int $id_address Current address id to change
|
||||||
|
* @param int $id_address_new New address id
|
||||||
|
*/
|
||||||
|
public function updateAddressId($id_address, $id_address_new)
|
||||||
|
{
|
||||||
|
$to_update = false;
|
||||||
|
if ($this->id_address_invoice == $id_address)
|
||||||
|
{
|
||||||
|
$to_update = true;
|
||||||
|
$this->context->cart->id_address_invoice = $id_address_new;
|
||||||
|
}
|
||||||
|
if ($this->id_address_delivery == $id_address)
|
||||||
|
{
|
||||||
|
$to_update = true;
|
||||||
|
$this->id_address_delivery = $id_address_new;
|
||||||
|
}
|
||||||
|
if ($to_update)
|
||||||
|
$this->update();
|
||||||
|
|
||||||
|
$sql = 'UPDATE `'._DB_PREFIX_.'cart_product`
|
||||||
|
SET `id_address_delivery` = '.(int)$id_address_new.'
|
||||||
|
WHERE `id_cart` = '.(int)$this->id.'
|
||||||
|
AND `id_address_delivery` = '.(int)$id_address;
|
||||||
|
Db::getInstance()->execute($sql);
|
||||||
|
}
|
||||||
|
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -215,25 +215,7 @@ class AddressControllerCore extends FrontController
|
|||||||
{
|
{
|
||||||
// Update id address of the current cart if necessary
|
// Update id address of the current cart if necessary
|
||||||
if (isset($address_old) && $address_old->isUsed())
|
if (isset($address_old) && $address_old->isUsed())
|
||||||
{
|
$this->context->cart->updateAddressId($address_old->id, $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)
|
if ($this->ajax)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user