Hey y’all!
Apologies if this has been covered before.
I’m working on building a discount function app that discounts a particular product group when all the items are in the cart together (pretty much a bundle but not using the bundle API).
I have it working the way I like it on its own, however we want to implement multiple versions of the discount at the same time. E.G.
- Bundle 1 discount: Product A, B, and C 12% off
- Bundle 2 discount: Product A, B, C, and D 20% off
This is where it gets interesting. I’ve set up the rust function run to count bundle components in the cart so that if the customer wants to add multiple bundles they can, but if you add a mismatch (e.g. 2 product A, 2 product B, and 1 product C) it splits out the line items so only one set gets the discount.
The problem is that if I have Bundle 1 in the cart and I add some items from bundle 2, it messes with the component counting function because it will just find the qualifying cart lines regardless if they have been discounted previously or not.
If I can flag a line item as belonging to Bundle 1 or Bundle 2 (or already having a discount applied to it) I should be able to apply that to the counting logic and not count them toward other bundles. Is there a way to do that? I’ve looked into selection strategy, but if I use First then users would only be able to add one bundle to the cart and get it discounted.
Here’s a quick(ish) video that visualizes the problem
Thanks for taking a look!