Zen Cart Edit Orders and my Discounting Mods

Recent versions of Zen Cart Edit Orders (4.3.1, for example) will get the wrong total for orders using my discounting mods (such as Better Together) when they edit an order.   The order is too low by the amount of the tax on the discount.  For example, at a tax rate of 7%, a discount of $25 would produce an order total that was $1.75 too low – for example, $506.50 instead of $508.25.

The fix is to change the function process() in the code file in includes/modules/order_total (e.g. includes/modules/order_total/ot_quantity_discount.php for Quantity Discounts) as follows:

if ($this->calculate_tax != 'VAT') {
     $order->info['total'] -= $od_amount[$key];


   if ($this->calculate_tax != 'VAT') {
      $order->info['total'] -= $od_amount[$key];

Using set_cart_discount in Zen Cart Big Chooser

The Zen Cart Big Chooser discounting module normally works in “Buy X, Get Y” mode – but you can configure it differently.  If you want to discount the entire package (X+Y) or even the entire basket if X and Y are purchased, you can use “set_cart_discount.”

The easiest way to understand this is with a series of examples. Suppose you have the items in your cart:

5x product 28  @$5: $25
1x product 29 @$10: $10
1x product 30 @$25: $25
Subtotal:           $60

If you used this offer

 $this->add_condition("Buy product 29 and 30, get 10% off your purchase", false); 
     $this->set_constraint(PROD, 29, 1, PROD, 30, 1); 
     $this->set_cart_discount("%", 10); 

the discount would be 10% of $60, or $6.

If you used this offer

 $this->add_condition("Buy product 29 and 30, get 10% off the pair", false); 
     $this->set_constraint(PROD, 29, 1, PROD, 30, 1); 
     $this->set_cart_discount("%", 10, CART_DISCOUNT_CONSTRAINTS_ONLY); 

the discount would be 10% of $35, or $3.50.

Free Gift Chooser for Zen Cart now does discounts!

Zen Cart Free Gift Chooser Mega Module version 1.1 now supports discounting by dollars or percentage in addition to free (100% discount). You can even create a final price discount for a group of products.

Free Gift Chooser supports the most common types of discounts people were building with Big Chooser – but with the convenience of an admin panel, instead of having to code the discounts in by hand.

Zen Cart Better Together now supports One to Many linkages

One to Many is a new feature in Better Together 2.5. It is best explained by example. Suppose you have the following discount structure:

      $this->add_prod_to_prod(27, 3, "%", 50);
      $this->add_prod_to_prod(27, 25, "%", 50);

Where 27 is the HP LaserJet Printer, 3 is the Mouse, and 25 is the keyboard.

Now suppose you have 1 product 27, and 2 product 3 and 2 product 5 in your cart.

The way Better Together has always worked is as follows: it would run the first rule, see that item 27 was in the cart, see that item 3 was in the cart, and discount item 3. Now item 27 would no longer be permitted for use in discounts, and that would be the end of the discount.

This is shown, using Discount Preview, by the following screenshot. Note that the discount is $20.00, 50% of the the price of the mouse (item 3).

Better Together One to Many = 0 (Classic Mode)

Better Together with One to Many = 0

Some people wanted the option of discounting both item the mouse and keyboard, even though there was only one printer in the cart. In Better Together 2.5, this can be done by setting the configuration option One to Many to 1 (in Admin->Modules->Order Total->Better Together). Note that the discount is now $54.99, which is half the price of the mouse (item 3) and the keyboard (item 27) combined.

Better Together One to Many = 1

Better Together with One to Many = 1

And finally, some people wanted unlimited mice and keyboards to be discounted, which can be done by setting One to Many to 2 (in Admin->Modules->Order Total->Better Together). Note that the discount is now $109.98, which is half off the price of two each of the mouse and the keyboard.

Better Together One to Many = 2

Better Together with One to Many = 2

Note: If you were running Better Together 2.4 or older and you download version 2.5 or higher, you must go to Admin->Modules->Order Total and Remove and Re-Install Better Together to get access to this feature.

Multiple VAT Levels and my Zen Cart discounts

Every once in a while, a European customer complains that tax recalculation in my Zen Cart mods is not working correctly for their store with multiple levels of embedded taxes.  (This is also an issue in osCommerce.)

Here’s what to look for: non-unique strings in the descriptions of taxes (this is shown in Admin->Locations/Taxes->Tax Rates)


Because of the way Zen Cart (and osCommerce) represent taxes in the order object, the tax descriptions must be unique to allow for reverse lookups.  So try changing the strings “Varav moms” to “Varav moms (1),” “Varav moms (2),” etc. to make them unique.

Zen Cart BOGO module update

A bug was found in BOGO Discount for Zen Cart, which will affect configurations using Discount Basis other than “No Restriction.”

The issue was that BOGO would not continue to other items after granting the first discount in these situations.  So if you have “Buy 1 Get 1 Free” with Discount Basis “Same Item”, and you had 2 of item 12 at $10.00 each, and 2 of item 15 at $5 each, it would only discount the item 12 (whereas the correct discount would be the item 12 + the item 15).

Thanks to the good folks at AliensAndStrangersMusic for helping me find this issue.