diff --git a/classes/Product.php b/classes/Product.php index f43b6da21..41ff38478 100644 --- a/classes/Product.php +++ b/classes/Product.php @@ -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; } diff --git a/classes/stock/StockAvailable.php b/classes/stock/StockAvailable.php index 2c9fe77af..d9da7a6bf 100644 --- a/classes/stock/StockAvailable.php +++ b/classes/stock/StockAvailable.php @@ -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) ); } diff --git a/controllers/front/CartController.php b/controllers/front/CartController.php index 020927664..69bdb834e 100644 --- a/controllers/front/CartController.php +++ b/controllers/front/CartController.php @@ -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')) {