[-] BO : Fix bad use of 'uninstanciated' variable product
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@14231 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
1 parent
7e1c0fcab6
commit
371e03a202
1 file changed
+15
-8
@@ -254,17 +254,24 @@ class AdminCartsControllerCore extends AdminController
|
|||||||
$errors[] = Tools::displayError('Invalid product');
|
$errors[] = Tools::displayError('Invalid product');
|
||||||
elseif (!($qty = Tools::getValue('qty')) || $qty == 0)
|
elseif (!($qty = Tools::getValue('qty')) || $qty == 0)
|
||||||
$errors[] = Tools::displayError('Invalid quantity');
|
$errors[] = Tools::displayError('Invalid quantity');
|
||||||
if (($id_product_attribute = Tools::getValue('id_product_attribute')) != 0)
|
|
||||||
|
// Don't try to use a product if not instanciated before due to errors
|
||||||
|
if (isset($product) && $product->id)
|
||||||
{
|
{
|
||||||
if (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !Attribute::checkAttributeQty((int)$id_product_attribute, (int)$qty))
|
if (($id_product_attribute = Tools::getValue('id_product_attribute')) != 0)
|
||||||
$errors[] = Tools::displayError('There is not enough product in stock');
|
{
|
||||||
|
if (!Product::isAvailableWhenOutOfStock($product->out_of_stock) && !Attribute::checkAttributeQty((int)$id_product_attribute, (int)$qty))
|
||||||
|
$errors[] = Tools::displayError('There is not enough product in stock');
|
||||||
|
}
|
||||||
|
else
|
||||||
|
if (!$product->checkQty((int)$qty))
|
||||||
|
$errors[] = Tools::displayError('There is not enough product in stock');
|
||||||
|
if (!($id_customization = (int)Tools::getValue('id_customization', 0)) && !$product->hasAllRequiredCustomizableFields())
|
||||||
|
$errors[] = Tools::displayError('Please fill in all required fields');
|
||||||
|
$this->context->cart->save();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
if (!$product->checkQty((int)$qty))
|
$errors[] = Tools::displayError('Product can\'t be added to the cart');
|
||||||
$errors[] = Tools::displayError('There is not enough product in stock');
|
|
||||||
if (!($id_customization = (int)Tools::getValue('id_customization', 0)) && !$product->hasAllRequiredCustomizableFields())
|
|
||||||
$errors[] = Tools::displayError('Please fill in all required fields');
|
|
||||||
$this->context->cart->save();
|
|
||||||
|
|
||||||
if (!count($errors))
|
if (!count($errors))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user