Search code examples
shopwareshopware6

Check if a rule is passed in Cart rules


I can see the rules applied to a cart with

CheckoutCartPageLoadedEvent

$event->getPage()->getCart()->getRuleIds()

but how can I know if a certain rule passed or not? For what I understand the RuleIds array contains all the rules evaulated, but I can't see if they are passed or not.


Solution

  • Both ruleIds list properties retrieved from either the current Context object or the current Cart object should only contain the ids of rule entities that evaluated to true. If an id is included, the rule's conditions were met, otherwise they weren't.