PDA

View Full Version : Tiered Quantity Discounts


Travis250923
03-19-2009, 04:57 AM
I like to see more in the way of discounts especially calculating a tiered discount. For example I sell an item for $1/ft but if you buy in 6ft sections you get a $1 discount for each 6ft section. Well what happens if you by 7ft or 13ft? I would want it to be $6 or $11 respectively. I know this would be a hard calc to program but I think it would be very helpful.

Ray Borduin
03-19-2009, 07:18 AM
Is this for every item or just the one?

If it is for every item, then you update the Total Price calculation to:

TotalPrice = ([Price] * [Quantity]) - floor([Quantity]/6)

And then maybe add a few calculations so you can display them on the page where you need to:

DiscountAmount = floor([Quantity]/6)

Now if you didn't want the discount to be applied automatically in the row, but want to show it below, then you wouldn't update the TotalPrice calculation and you would just add the DiscountAmount and define a Discount rule for the total of that Column.



I assume you use Quantity for your length in feet... if not substitite it for the eCart column name you are using.

Ray Borduin
03-19-2009, 07:21 AM
If you only wanted this for a particular item like item ID 36, then you would use something like:

TotalPrice = ([Price] * [Quantity]) - (([ID] == "36")?floor([Quantity]/6):0)

And then maybe add a few calculations so you can display them on the page where you need to:

DiscountAmount = (([ID] == "36")?floor([Quantity]/6):0)

The calculations are actually very easy and just about any discount is possible by using simple algebra.

Travis250923
03-19-2009, 09:53 AM
Thanks for the help. My problem is that I don't really know PHP (I am working on learning it) and how to properly format the calcs. In your example I understand most of it but I don't understand what this is doing:

floor([Quantity]/6):0

I would like to do this on a particular item and have a similar calc that I am trying to do where items are .75 each but sold 3 for $2. So if someone buys 4 the should be $2.75...I assume I would do something similar for this as well?

Ray Borduin
03-19-2009, 10:12 AM
In that case, you would add a column to your cart called: BreakQty
and add another column called: BreakAmt

Then for each item you will be able to specify the amount you need to buy to trigger the discount and the amount of the discount.

Then your calculation becomes:
TotalPrice = ([Price] * [Quantity]) - (([BreakQty] != "0")?floor([Quantity]/[BreakQty])*[BreakAmt]:0)

And your DiscountAmount = (([BreakQty] != "0")?floor([Quantity]/[BreakQty])*[BreakAmt]:0)

Then you will have complete flexability over each items discount threshold and discount amount on an item by item basis.

Floor is a mathematical term to round down to the nearest whole number. So floor(1.99) is 1. This is what handles not giving partial discounts for each item and only giving the discount for every third or sixth... since floor(7/6) is still 1 and the floor of (13/6) is still 2, this gives you the number of times the discount should be applied according to your description.

Travis250923
03-19-2009, 10:58 AM
Thanks i'll play with this tonight. I assume I would place these in the spot for custom expression in the discount screen? I don't have it in front of me right now.

Thanks

Ray Borduin
03-19-2009, 11:25 AM
Yes... that is correct

Travis250923
03-20-2009, 08:00 AM
Ok so the first one to alter the price works. But if I use this for the other item I don't see how it will work because floor is going to round to the nearest integer yet when buying 4 pieces the price should be 2.75 which using floor would bring it down to $2 right? Perhaps there is some place you know of that I can read up on this to better understand it?

I'm also not sure what I'm doing with the DiscountAmount calc you show.

Ray Borduin
03-20-2009, 09:06 AM
.75 each but sold 3 for $2... lets say 4 items

Formula with the numbers replaced would then be:

TotalPrice = (0.75 * 4) - ((3 != "0")?floor(4/3)*0.25:0)

which is equal to:

TotalPrice = 3 - (1 * 0.25)

or TotalPrice = 2.75

The formula is correct. Have you tried it?

Travis250923
03-20-2009, 09:41 AM
Ahh I was misunderstanding where/when 'Floor' was applied. That makes sense. I haven't tried it because I was having problems with the calculation tab that I need to enter a supp ticket for. Every time I tried to add a calc eCart kept truncating it.

I would enter:

(([ID] == "36")?floor([Quantity]/6):0)

Press the Enter Key and then it would change to be (([ID] ==

I got frustrated last night and gave up. I have since found that if I click on another tab I am asked to save the calc which then saves it but I haven't had a chance to test it out yet because I need to add the new columns, update my database and then set the cart to populate populate these columns.

Travis250923
03-20-2009, 07:01 PM
So I got that working thanks again. I did have set the breakqty to default to 1 otherwise I was getting an error because it was dividing by zero.