Delete item from existing cart if product out of stock - prestashop 1.7
//Delete product from the cart if product out of stock
Add in shouldProductsAvailable function which is in cartcontroller.php
$cart = $this->context->cart;
$cart_products = $cart->getProducts();
$array_name=array();
foreach($cart_products as $key=>$value)
{
$flag=1;
if( ($value['stock_quantity']<=0 || $value['cart_quantity']<=0) && (!Product::isAvailableWhenOutOfStock($product['out_of_stock'])) )
{
$array_name[]=$value['name'];
$flag=0;
$this->context->cart->deleteProduct($product['id_product'],$product['id_product_attribute'], $product['id_customization'], $product['id_address_delivery']);
}
}
$product_array=implode(" , The item ",$array_name);
Comments
Post a Comment