Situation:
- There are 4 products in the cart
- One of these products causes a cart rule to apply
By getting the cart items via code, I need to be able to identify the one item that is causing the rule to apply.
My problem is that I cannot find a way to separate this item from the others in the cart, they all return the same results.
My code so far:
foreach($quote->getItems() as $quoteItem) {
$itemAppliedRulesId = $quoteItem->getAppliedRuleIds(); // I expect this to give a result only for the one item that matches the cart rule, instead all the items returns the rule id
$product = $quoteItem->getProduct();
$result = $rule->getActions()->validate($product); // see comment above, same result
}
My question:
Is there a way I can get the items of the cart that cause one or more rules to apply?