Qty-based discounts (amount and percent)



This will allow you to establish quantity-based discounts on specific items sent to PayPal. Each item has its own discount structure that you must set up, and the discount table does not exist beyond any item.. Cart-wide discounts (4 of one item, or 2 of 2 different items) simply require your own shopping cart. The reason is in the next paragraph.

The most important thing to understand when considering discounts is that the customer may change the quantity of items ordered once he is within the PayPal shopping cart, and there is no way for you to detect this.

Because of this we have to play a little game. Every order must be considered a single package of n items. So PayPal reports a quantity of 1, but we modify the description to report a package of n items. And we must calculate the qty * price for the total price of the package. See how it works before you judge too harshly. This is really the only way to do it properly.

We are going to create user-defined tables of quantity/amount pairs, or quantity/percent pairs, that describe our discount structure.

SetAmt (q1, a1, q2, a2, ...);  // amount based
SetPer (q1, p1, q2, p2, ...);  // percent based

  where
    q1 = quantity 1 breakpoint
    a1 = amount charged above that breakpoint
    p1 = percent discount above breakpoint
    q2 = quantity 2 breakpoing
    a2 = amount charged above that breakpoint
    p2 = percent discount above breakpoint
    ...

Notice in the JS we run this table backwards to find the first quantity that is less than what the customer ordered. This is how to navigate such tables.

We start with the output of the PayPal button factory and make a few changes. Then the JS processes the FORM and adjusts the fields. Right-click on this page (and <view source>) to see what was done.

  • Copy the JS from this example and paste it into your page within the <head> section, like is done on this page, or into the <body> section. Only one copy of the JS is needed for any page. There is nothing you will ever have to change in the JS. It is all in the SetDis call, and the structure of the event handler (EH).
  • Go into every FORM that can place an order and add these things...
    • A new named element called baseamt to hold the base amount of the item.
    • A new named element called basedes to hold the base description of this item.
    • An event handler to the "FORM" like was done here. You must place two things in the EH - The SetAmt or SetPer, and the ReadForm calls. Do it like is done on this page, but insert the table breakpoints you want in the Set... calls.



[picture] Blah, blah. $10.00 each.

Pricing discounts...

	1 - 4  $10 each
	5 - 9  $9  each
	10 up  $8  each

Input Quantity >      



[picture] Blah, blah. $10.00 each.

Pricing discounts...

  1 - 4  $10 each
  5 - 9  9% off
  10 up  13% off

Input Quantity >      



Back To Main Page



info@capleswebdev.com