# Volume Discounts? #52

Closed
opened this issue Jul 31, 2010 · 22 comments

### jdawson commented Jul 31, 2010

 Wondering if there was a way through simplecart.js to apply volume disounts. (e.g., 20% Off 3 or more, 30% off 5 or more, etc.) Thanks, John

### feliper commented Nov 16, 2010

 Hi John, you need to find this line outputValue = me.valueToCurrencyString(parseFloat(item.price)*parseInt(item.quantity,10) ); and add a discount value, if (quantity>3) price * quantity * DISCOUNT1 else if (quantity>5) price * quantity * DISCOUNT2 else price * quantity Regards, Felipe

### kellyrnh commented Mar 21, 2011

 I am looking to do this too, can you explain further? I just want to give a discount if the cart has 20+ items in it. Essentially change the price from 14.99 to 9.99, (multiplying the amt by .6666 works for this). I just can't seem to implement this in my script?

### feliper commented Mar 22, 2011

 Hello ... jus add the discount only if quantity>20 var discount = 0.666 if (quantity<20){ outputValue=me.valueToCurrencyString(parseFloat(item.price)_parseInt(item.quantity,10)); } else{ outputValue=me.valueToCurrencyString(parseFloat(item.price)_parseInt(item.quantity,10)*discount); }

### kellyrnh commented Mar 22, 2011

 Thank you so much for responding! I must still be doing something wrong, as it doesn't seem to be working. I added your code after: switch( info[0].toLowerCase() ){ case "total": outputValue = me.valueToCurrencyString(parseFloat(item.price)*parseInt(item.quantity,10) ); break; Is that correct, or should it be somewhere else? Thanks again!!!

### feliper commented Mar 22, 2011

 Hi, this code is working for me // Here is where TOTALS are updated me.updateTotals = function() { ... if( item.price ){ if (item.quantity<5) { me.total = parseFloat(me.total) + parseInt(item.quantity,10)_parseFloat(item.price) ; } else { me.total = parseFloat(me.total) + (parseInt(item.quantity,10)_parseFloat(item.price)*DISCOUNT) ; } } ... ... // And here is where the TOTAL of each ROW is updated switch( info[0].toLowerCase() ){ case "total": if (item.quantity<5){ outputValue = me.valueToCurrencyString_def(parseFloat(item.price)_parseInt(item.quantity,10)); } else { outputValue = me.valueToCurrencyString_def(parseFloat(item.price)_parseInt(item.quantity,10)*DISCOUNT); } ...

### kellyrnh commented Mar 22, 2011

 Yes, that worked! Thank you so much! You just made my day :) I had looked for a solution for days now and was about to pull my hair out lol.

### kellyrnh commented Mar 24, 2011

 Another question - I just realized that this only works when you add the right number to the cart for one item (for me the person must have at least 20 items in their cart to get the discount). I need this to just look at the total number of items in the cart (so they can do 3 of itemX, 17 oof itemY and still get the discount). Thoughts? Thanks aggain!!!

### feliper commented Mar 24, 2011

 In this case, you need to look for the TOTAL quantity, just a few lines before the "if( item.price ){" there´s a "if( item.quantity < 1 ){" where the "me.quantity" value is the TOTAL quantity, you must apply here the conditional instead of the other place Regards !!

### kellyrnh commented Mar 24, 2011

 Again, thank you so much for your help. Can you clarify? Which conditional statement (you had given me two to add in previously) and seems that I've already added in there? Ugh, sorry...but it is GREATLY appreciated!

### kellyrnh commented Mar 28, 2011

 Could you maybe let me know where to put each of the following lines so it checks the cart total for the required minimum to get the discount: if (item.quantity<5) { me.total = parseFloat(me.total) + parseInt(item.quantity,10)_parseFloat(item.price) ; } else { me.total = parseFloat(me.total) + (parseInt(item.quantity,10)_parseFloat(item.price)*DISCOUNT) ; } and if (item.quantity<5){ outputValue = me.valueToCurrencyString_def(parseFloat(item.price)_parseInt(item.quantity,10)); } else { outputValue = me.valueToCurrencyString_def(parseFloat(item.price)_parseInt(item.quantity,10)*DISCOUNT); } Thanks again!!!!

### feliper commented Mar 28, 2011

 Hi, that´s completely different, so forget everything, you should do this ... me.updateTotals = function() { ... for( var current in me.items ){ ... } if (me.quantity>5) { me.total = me.total*DISCOUNT } explanation: if TOTAL quantity > 5 then apply discount to me.total, me.total is the sum of total per each row, without the shipping and tax values regards !!

### kellyrnh commented Mar 28, 2011

 Ok, tried that but doesn't seem to affect the price at all...thoughts? Thanks!

### feliper commented Mar 28, 2011

 This works for me ... notice that this only affect to the TOTAL price, not the individuals ... You leave the other changes as the original file ?? you only need to add this line if (me.quantity>5) { me.total = me.total*DISCOUNT } just before the me.shippingCost = me.shipping(); line, inside the me.updateTotals = function() good luck !!

### kellyrnh commented Mar 28, 2011

 OMG, it does work, thank you! I was testing the wrong amount of items, UGH, sorry. Thanks so much for your help, you are a life saver!!!
1 similar comment

### kellyrnh commented Mar 28, 2011

 OMG, it does work, thank you! I was testing the wrong amount of items, UGH, sorry. Thanks so much for your help, you are a life saver!!!

### kellyrnh commented Mar 29, 2011

 I hate to bother you again...in my site it is working great (thank you!). But when you click "checkout" the discount is not showing in paypal? Help! Thanks again!!!

### feliper commented Mar 29, 2011

 Hi ... that´s not so easy, because SimpleCart sends to Paypal the data of each row and not the totals, with the data, Paypal system gives you the total amount. In your case discounts are applied over the totals I ´m not sure but maybe there´s a variable in Paypal for discounts, take a look at this doc https://www.x.com/docs/DOC-1331 good luck !!

### kellyrnh commented Mar 29, 2011

 Hmm. This seems to be a problem. Not seeing how to do it with PayPal. Is there any way to do what we are doing - if someone totals 20 items or more the products are all discounted 33% (x .6666) but instead of just discounting the total cart, we can have the item discounted by the row? Simply stated, if the cart totals 20 or more items, each row gets a 33% discount? Possible?

### andreagiLiljewall commented May 4, 2011

 Can I do the same, but with shipping. Like: if total shipping cost is larger than 500, reduce the totals with 100? Maybe: if (me.shipping>500) { me.total = me.total*DISCOUNT } ????
Collaborator

### ghost commented Jun 7, 2011

 Currently this is not possible without modifying the cart script, it will be worked in to a future version so prices can be created with a function.
Collaborator

### brettwejrowski commented May 2, 2012

 closed due to inactivity

### misbach commented Aug 8, 2013

 @brettwejrowski @feliper It looks like the code has changed significantly since this issue thread was closed. I'm stuck trying to implement a volume discount per item. Can you give me some guidance on how to do it in today's code? thanks.
referenced this issue Aug 8, 2013