diff --git a/modules/mailalerts/mailalerts.php b/modules/mailalerts/mailalerts.php index f10151f81..485240d43 100644 --- a/modules/mailalerts/mailalerts.php +++ b/modules/mailalerts/mailalerts.php @@ -452,16 +452,20 @@ class MailAlerts extends Module public function hookActionUpdateQuantity($params) { $id_product = (int)$params['id_product']; + $product = new Product($id_product); + $product_has_attributes = $product->hasAttributes(); $id_product_attribute = (int)$params['id_product_attribute']; $quantity = (int)$params['quantity']; $context = Context::getContext(); $id_shop = (int)$context->shop->id; $id_lang = (int)$context->language->id; $product = new Product($id_product, true, $id_lang, $id_shop, $context); - $configuration = Configuration::getMultiple(array('MA_LAST_QTIES', 'PS_STOCK_MANAGEMENT', 'PS_SHOP_EMAIL', 'PS_SHOP_NAME'), $id_lang, null, $id_shop); + $configuration = Configuration::getMultiple(array('MA_LAST_QTIES', 'PS_STOCK_MANAGEMENT', 'PS_SHOP_EMAIL', 'PS_SHOP_NAME'), null, null, $id_shop); $ma_last_qties = (int)$configuration['MA_LAST_QTIES']; - - if ($product->active == 1 && (int)$quantity <= $ma_last_qties && !(!$this->_merchant_oos || empty($this->_merchant_mails)) && $configuration['PS_STOCK_MANAGEMENT']) + + $check_oos = ($product_has_attributes && $id_product_attribute) || (!$product_has_attributes && !$id_product_attribute); + + if ($check_oos && $product->active == 1 && (int)$quantity <= $ma_last_qties && !(!$this->_merchant_oos || empty($this->_merchant_mails)) && $configuration['PS_STOCK_MANAGEMENT']) { $iso = Language::getIsoById($id_lang); $product_name = Product::getProductName($id_product, $id_product_attribute, $id_lang);