3
Answers
Vote up!
0
Vote down!

Bulk Discount Headaches

Hey guys,

could anyone recommend a good way to do bulk discounts taking into account all of the variations of a product in the cart.

For example, if I have a shirt with 6 sizes, I want someone to be able to mix and match their sizes and still get the discount an every shirt. So if I give 1 dollar off per shirt when you buy 20 shirts, then if someone buys 8 smalls, 8 mediums, and 8 larges (24 shirts), I want them to be able to save the dollar per shirt on ALL of those sizes. Right now someone would have to buy 20 of each size before the discount kicks in.

I feel like i am missing something obvious, but for the life of me, i cannot seem to get it to work.

I would very much appreciate any help.

Thanks!

Asked by: timothydbailey
on May 1, 2014

3 Answers

Vote up!
0
Vote down!

I don't think you're missing anything obvious - this is actually a tricky problem. : D

The issue, of course, is that product pricing is enacted at the line item unit price level where all we have is a reference to the particular SKU the line item represents, not the node ID that may group related SKUs together. I'm honestly not sure this is even worth pursuing with the default Rules conditions / actions, because the logic is just complicated enough that it would take longer to do that than to code a custom condition.

If I were developing a site with such a requirement (and I've come close! I actually have this coming up in a project slated to start in July), I'd create a custom Rules condition that would examine all product line items on a cart to find the total quantity of all products added to the cart through the same Add to Cart form. In pseudo code, it would look something like:

1. Look in the line item's data array to find the reference to the entity containing the grouping product reference field. This is stored in a context array that's intended to be used to rebuild the form if necessary.
2. Extract the related product IDs from the referencing entity.
3. Loop over all the line items on the current line item's order looking for product line items that reference any of those product IDs.
4. Sum the quantities of all matching line items.
5. Compare the final sum against a parameter from the condition using a configurable operator.

Not sure how much that helps, but suffice it to say I can't imagine trying to make that all work through the Rules UI.

Ryan Szrama
Answer by: Ryan Szrama
Posted: May 1, 2014
Vote up!
0
Vote down!

Thanks so much Ryan. This is exactly what I needed to know. I had been trying to do this with rules and debating whether I should just dive into something custom. So this ends that debate for me.

I will definitely program something custom.

Again, thanks for pointing me in the right direction!

Answer by: timothydbailey
Posted: May 2, 2014
Vote up!
0
Vote down!

Hi ,

very interesting issue.

I like it because it is much more generic then for example the Price Table module.
The solution discussed here can be used on display node level, what is very cool when you have a lot of variations referenced by one single display node.

timothydbailey,
how did you finally solve this?

Ryan,
did you use this successfully in your project in July?

Thanks!

Answer by: Max Acke
Posted: Dec 31, 2014