Adding Up Quantity
I have a very specific use case for this question, that may or may not be able to be answered here, so bear with me, but I have to figure this out in a few days for a client, so I'm a bit stressed, so bear with me.
I have a client that wanted to add break points in cases order through Drupal Commerce. That was easy enough to accomplish with Commerce Price Table (https://drupal.org/project/commerce_price_table). All the productions have the same price breaks (10-25, 26-75, 75+). All of this is accomplished, and was easier enough to configure. But here is the kicker; They want all the items added to tally up the quantity added to equal all the price breaks. So, say for instance they bought 5 cases of one item, and 5 cases of another, both items would get the 10 case price break.
I somewhat have it working, using rules. I modified the the price table rule that is created when activating the module. The event is set to "Calculating the sell price of a product", my condition is set to the particular product type I have this set on, and here is where is gets messy.
Actions:
I created a loop, created a list of "order:commerce-line-items", gave it a variable of total. Added an action calculating a value using "total:quantity" + "total:quantity" and giving it the variable name mm_total, I did so thinking it would that the loop would just continuously grab the quantity and add to it each pass it made on the item. I then used "replace price for price table", set it to "commerce-line-item", using a quantity value of mm-total. So in theory it checks against the total quantity and sets the price in the appropriate quantity bracket.
Well, it works, it does pull the correct prices based on the total quantity, but here is the weird thing I can't figure out. If the quantity value is lower than an item above it (i.e. item-1 is a quantity of 70, item-2 is a quantity of 60) then it no longer gives any value to quantity at all to get the price breaks. It's as if, at that point, each item has a quantity of 1, even though they don't. If the quantities are switched, it works again. As long at the quantities down the list increase, it works, if they decrease, it breaks. Not sure how to fix this, but I know it has to do with out my actions are setup, I just can't seem to find a different alternative.
If anyone has any advice it would be greatly appreciated. Thank you in advance.