// Fix out of stock on combinations with no quantity (thank you Brice <3)

This commit is contained in:
rMalie
2012-05-30 13:48:23 +00:00
parent 4e195970e7
commit 2f5dd84019
3 changed files with 5 additions and 5 deletions
+1 -1
View File
@@ -1069,7 +1069,7 @@ class ProductCore extends ObjectModel
if ($this->getType() == Product::PTYPE_VIRTUAL)
StockAvailable::setProductOutOfStock((int)$this->id, 1, null, $id_product_attribute);
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;
}
+1 -1
View File
@@ -242,7 +242,7 @@ class StockAvailableCore extends ObjectModel
'stock_available',
array('out_of_stock' => (int)$out_of_stock),
'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)
);
}
+3 -3
View File
@@ -223,14 +223,14 @@ 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, Tools::getValue('op', 'up'), $this->id_address_delivery);
if ($updateQuantity < 0)
$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 ($update_quantity < 0)
{
// 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;
$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);
elseif ((int)Tools::getValue('allow_refresh'))
{