How to apply different discount types in the shopping cart

So this is what I’m confronted with in one of my ecommerce projects: The client offers all kinds of discounts for their products, like …

  • when customer buys before a certain date
  • when customer buys all products in a certain group
  • when customer is member with a special status (wholesaler doesn’t cut it here; there’re 3 different status levels)
  • when customer is member with another special status and buys all products in a certain group
  • when customer is making a salto before hitting “buy” (okay, just kidding :slight_smile: )

All of these discount types can show up in a customer’s shopping cart. Some fancy Liquid will do the calculation of the total discount. So far so good. But how do I apply the total discount to the price for checkout?
The only way to I could figure out so far is to set up a series of discount codes covering the entire range of possible total discounts, name them according to their respective discount amounts, then auto-populate the discount code field (which is hidden) with the right code to apply the total discount.
I would really like to go for something simpler and more robust!
@vlad.z Is there anything on the roadmap which would help me out here?

PS: Thinking about using attributes at least for the different membership status discounts. Like setting up attributes for different status levels, hide them and auto-populate them depending on the customers status. But this would need to be done for every product and again for new products, opening an additional possible point of failure on the admin level.

Ideally there would be a way to push any discount amount to checkout via Liquid, without the neccassity of preset discount codes. But I’m curious what other partners think.

1 Like

The only way to reduce the price of a product or the checkout is via a pre-configured discount code. So I think your idea with the range of discount codes is probably the way to go.

The only other way I’ve managed to control the product prices and cart total in a customised way is by coming at it the other way around. Were all products have an actual price of $0.01 (with base price, for calculations, stored in a custom field) and I use quantity to build the price up to what it needs to be.
But this was a special case project where quantity didn’t need to be used otherwise and could be hidden completely and it also introduced a bunch of other issues that needed to be overcome… so not sure if this method would be feasible in your case.

But, I have another crazy idea which is purely theoretical and may also introduce other unforeseen issues :slight_smile:
It involves programmatically ADDING to the cart in order to REDUCE it… say what? :face_with_raised_eyebrow:
So, let’s say you just have one discount code set and it’s configured as a 50% off discount.
Product/s are added to the cart and total $100.
Your Liquid/JS script calculates the user is eligible for a $10 discount.
So the TARGET total of the cart is $90.
If you apply the 50% discount code now it would reduce the cart total to $50 (not what we want).
So in order to get the cart total to the TARGET $90 we can programmatically ADD a hidden product (of say $1) to the cart with a quantity of x80 (2 x 40).
Cart total (still with 50% discount applied) now becomes $90.
Ensure this product line is always hidden in the cart and invoice and the customer is none the wiser.

So all of this should be able to be calculated programmatically and I think it’ll work for any value… but maths is not my strong suit :slight_smile:

I’d guess, that the hidden product would probably need to have a price of $0.01 and the quantity increased x100, but I just used $1 in the example above for simplicity.

1 Like

By the way, there would probably be more options and control for this type of thing with this backlog item implemented (hinting for votes):

1 Like