[-] FO : automatic refresh of the cart when a cart rule is added
This commit is contained in:
@@ -34,6 +34,8 @@ class CartControllerCore extends FrontController
|
||||
protected $id_address_delivery;
|
||||
protected $customization_id;
|
||||
protected $qty;
|
||||
|
||||
protected $ajax_refresh = false;
|
||||
|
||||
/**
|
||||
* This is not a public page, so the canonical redirection is disabled
|
||||
@@ -111,7 +113,9 @@ class CartControllerCore extends FrontController
|
||||
$this->context->cart->update();
|
||||
}
|
||||
}
|
||||
CartRule::autoRemoveFromCart();
|
||||
$removed = CartRule::autoRemoveFromCart();
|
||||
if (count($removed))
|
||||
$this->ajax_refresh = true;
|
||||
}
|
||||
|
||||
protected function processChangeProductAddressDelivery()
|
||||
@@ -215,6 +219,7 @@ class CartControllerCore extends FrontController
|
||||
|
||||
if (!$this->errors)
|
||||
{
|
||||
$cart_rules = $this->context->cart->getCartRules();
|
||||
$updateQuantity = $this->context->cart->updateQty($this->qty, $this->id_product, $this->id_product_attribute, $this->customization_id, $this->id_address_delivery, Tools::getValue('op', 'up'));
|
||||
if ($updateQuantity < 0)
|
||||
{
|
||||
@@ -224,9 +229,18 @@ class CartControllerCore extends FrontController
|
||||
}
|
||||
else if (!$updateQuantity)
|
||||
$this->errors[] = Tools::displayError('You already have the maximum quantity available for this product.', false);
|
||||
else
|
||||
{
|
||||
$cart_rules2 = $this->context->cart->getCartRules();
|
||||
if (count($cart_rules2) != count($cart_rules))
|
||||
$this->ajax_refresh = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
CartRule::autoRemoveFromCart();
|
||||
|
||||
$removed = CartRule::autoRemoveFromCart();
|
||||
if (count($removed))
|
||||
$this->ajax_refresh = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -255,6 +269,8 @@ class CartControllerCore extends FrontController
|
||||
{
|
||||
if ($this->errors)
|
||||
die(Tools::jsonEncode(array('hasError' => true, 'errors' => $this->errors)));
|
||||
if ($this->ajax_refresh)
|
||||
die(Tools::jsonEncode(array('refresh' => true)));
|
||||
|
||||
if (Tools::getIsset('summary'))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user