// Fix out of stock on combinations with no quantity (thank you Brice <3)
This commit is contained in:
+1
-1
@@ -1069,7 +1069,7 @@ class ProductCore extends ObjectModel
|
|||||||
if ($this->getType() == Product::PTYPE_VIRTUAL)
|
if ($this->getType() == Product::PTYPE_VIRTUAL)
|
||||||
StockAvailable::setProductOutOfStock((int)$this->id, 1, null, $id_product_attribute);
|
StockAvailable::setProductOutOfStock((int)$this->id, 1, null, $id_product_attribute);
|
||||||
else
|
else
|
||||||
StockAvailable::setProductOutOfStock((int)$this->id, 2, null, $id_product_attribute);
|
StockAvailable::setProductOutOfStock((int)$this->id, StockAvailable::outOfStock($this->id), null, $id_product_attribute);
|
||||||
return $id_product_attribute;
|
return $id_product_attribute;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -242,7 +242,7 @@ class StockAvailableCore extends ObjectModel
|
|||||||
'stock_available',
|
'stock_available',
|
||||||
array('out_of_stock' => (int)$out_of_stock),
|
array('out_of_stock' => (int)$out_of_stock),
|
||||||
'id_product = '.(int)$id_product.
|
'id_product = '.(int)$id_product.
|
||||||
' AND id_product_attribute = '.(int)$id_product_attribute.
|
(($id_product_attribute) ? ' AND id_product_attribute = '.(int)$id_product_attribute : '').
|
||||||
StockAvailable::addSqlShopRestriction(null, $id_shop)
|
StockAvailable::addSqlShopRestriction(null, $id_shop)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,14 +223,14 @@ class CartControllerCore extends FrontController
|
|||||||
if (!$this->errors)
|
if (!$this->errors)
|
||||||
{
|
{
|
||||||
$cart_rules = $this->context->cart->getCartRules();
|
$cart_rules = $this->context->cart->getCartRules();
|
||||||
$updateQuantity = $this->context->cart->updateQty($this->qty, $this->id_product, $this->id_product_attribute, $this->customization_id, Tools::getValue('op', 'up'), $this->id_address_delivery);
|
$update_quantity = $this->context->cart->updateQty($this->qty, $this->id_product, $this->id_product_attribute, $this->customization_id, Tools::getValue('op', 'up'), $this->id_address_delivery);
|
||||||
if ($updateQuantity < 0)
|
if ($update_quantity < 0)
|
||||||
{
|
{
|
||||||
// If product has attribute, minimal quantity is set with minimal quantity of attribute
|
// If product has attribute, minimal quantity is set with minimal quantity of attribute
|
||||||
$minimal_quantity = ($this->id_product_attribute) ? Attribute::getAttributeMinimalQty($this->id_product_attribute) : $product->minimal_quantity;
|
$minimal_quantity = ($this->id_product_attribute) ? Attribute::getAttributeMinimalQty($this->id_product_attribute) : $product->minimal_quantity;
|
||||||
$this->errors[] = sprintf(Tools::displayError('You must add %d minimum quantity', false), $minimal_quantity);
|
$this->errors[] = sprintf(Tools::displayError('You must add %d minimum quantity', false), $minimal_quantity);
|
||||||
}
|
}
|
||||||
elseif (!$updateQuantity)
|
elseif (!$update_quantity)
|
||||||
$this->errors[] = Tools::displayError('You already have the maximum quantity available for this product.', false);
|
$this->errors[] = Tools::displayError('You already have the maximum quantity available for this product.', false);
|
||||||
elseif ((int)Tools::getValue('allow_refresh'))
|
elseif ((int)Tools::getValue('allow_refresh'))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user