This example will show you how to detect if a certain product or a list of products were added to the cart, for example, to apply a special discount when purchasing several bundled products.
Take a look at the formula, we are using a function called CFO_CountProductInCart to check in current cart if the customer has added at least two products of a list of 4.
It uses product_id number, which can be seen easily in the URL of the product.
You can use CFO_CheckProductInCart too, which only returns true or false without returning quantity added.
We apply the special discount to ProductA if at least two products of B, C and D are added before.
Lines 3, 4 and 5 are using inline IF, take a look at the syntax if you are in doubt: Ternary Operator
To test the demo
– Go to Category Bundled Products and add to cart for example ProductB and ProductC.
– Enter in ProductA and add it to the cart, which is the product that has a special discount if other two were added.
– Look at the cart how ProductA has a detail that says “Purchase details: Bundle Discount 25%”
– Now, if you delete for example ProductB from the cart, the formula will detect it and remove the discount in ProductA, you will see “Purchase details: Regular price”