In Craft Commerce 3, there is a Order Condition Formula that allow us to condition for the discount. So here is my Case.

  • I have product A and Product B, so I will give a discount to Product A if the costumer buy 3 of Products B.

I tried to use this formula

order.lineItems|filter(v => (v.sku == 'SKU A' and qty >= 3) )

but the filter is not allowed in this formula, so is there any other way to approach this?

1 Answer 1


We will need to uncomment this line to allow |filter used in condition formulas:


If you do that manually yourself this formula works:

order.lineItems|filter(v => (v.sku == 'BBB' and v.qty >= 3) )

You were missing the v. in front of qty.

Look in the next version of commerce for the |filter being available.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.