Magento – Magento2: Cart price rule not applying

magento2shopping-cartshopping-cart-price-rules

Bit of a strange one here I think. Using Magento 2 all I want to do is give a 10% discount on three products when a certain three products are in the cart.

I have gone to "cart price rules -> actions". If ALL of these conditions are TRUE. SKU is PRODSKU1, PRODSKU2, PRODSKU3. Then added 10% discount.

For some reason this just doesn't work. If I change "SKU IS" to "SKU IS ONE OF" it does work, but obviously that's not quite the rule I want. I want them ALL to be in the cart. Any help?

If it sheds any light, all three SKUs I am adding are from the same configurable product.

Best Answer

You can make these changes directly in the cart.phtml

Above everything on the cart.phtml you can check the current customer's cart and check if all three products exist on the page.

If they do then you grab each product using

$product = $this->getProduct();
$price = <newPriceThatyouWant>
$product->setData('price', <newPriceThatyouWant>)->getResource()->saveAttribute($product, 'price');

you have to use $this when defining the product or else it will update the price in general. ask any questions you want to me and i'll get to them asap

Related Topic