1

I want to make a promotion where at a certain cart total threshold, if a particular product is in the cart, it would be free. (e.g. spend $50 and get a free mug).

Trying to sketch out the best way to achieve this.

It seems like if a discount had a a "Cart total" condition, I could pull it off w/o a custom adjuster. It has "Purchase Total", but that says only applies to the matching products, not the entire cart. In this case I would want to select the mug in the "products" condition, and set the percent discount to 100% (I think).

Any ideas where to start?

1

I don't think avoiding an adjuster or plugin approach here really gains you anything much and it probably creates potential issues - it will likely just make the discount rules confusing as you can't really document the special conditions anywhere on those rules etc (and experience shows over time editors are likely to forget the special conditions and make mistakes with these sorts of hidden logic approaches).

Personally I would approach this by listening to onAddToCart and onRemoveFromCart

https://craftcommerce.com/docs/events-reference#commerce_cart.onaddtocart https://craftcommerce.com/docs/events-reference#commerce_cart.onremovefromcart

In each of these I would call a function that inspects the order total and either adds the free item (if not already in the cart) if the total is high enough, or removes it if it is present but the order total slips below the desired total. And you'd want to look at the item total, not the cart total presumably.

To make it editor friendly, I would also add a control panel page that allows the editors to set the cart total threshold and the free product they get if the threshold is exceeded.

| improve this answer | |
  • Thanks Jeremy! One wrinkle is that the "free item" is also available for purchase in the store (an its normal price), so while I'd use onAddToCart/onRemoveFromCart to automatically add it in my condition, I'd also need an adjuster to make it free. Is that how you're seeing it? Yeah the only reason I was curious if it could be done without an adjuster was to keep it under client control (and in the "promotions" section). – Tim Kelty Nov 14 '17 at 12:33
  • You could just duplicate the item perhaps - one a free version not normally shown, the other the main one?? Or you could use onPopulateLineItem perhaps to do the free making bit...but your adjuster, or however you do it, can add a CP section of its won fairly easily - we have a whole 'Tools' section where a bunch of those things live. Ideally would be in Commerce itself but it's a relatively good solution even so... – Jeremy Daalder Nov 15 '17 at 1:14

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.