Zen Cart custom software development, Zen Cart modules, Zen Cart Expert eCommerce Websites with Zen Cart!

osCommerce Discount Chooser

osCommerce Discount Chooser Mega Module

Discount Chooser Mega Module for osCommerce (formerly Free Gift Chooser) simplifies the process of creating discounts based on items in the cart. It's almost like Big Chooser with an Admin panel!

Background: See the osCommerce Matrix-o-discounts.

Example Discounts: I have provided several examples of osCommerce Discount Chooser discounts.

Relevance: osCommerce 2.2, 2.3
You must have JavaScript enabled in your browser.

Current Version: 1.1a. Occasionally, new features are documented prior to being publicly available; please check the version history to ensure the feature you want is available in your version.

Support Thread: My commercial software is not supported on the osCommerce forum. Please email me questions instead.

Cost: $60 (Note: this low price covers software only for self-installation)

Buy Now

Would you like to ask me questions before buying? I'm happy to help likely purchasers make the right decision. Just use my contact form.

Installed Cost: $120.00 (Professional installation by That Software Guy) Note that this does not include payment gateway integration - see above. Please test my free software first (Better Together or Quantity Discounts) to ensure that this will work with your payment gateway.

Installation Difficulty: Moderate

Installation Instructions: See README.txt in mod

Common Installation Issues: click here

Payment Gateway Integration Note that some payment modules, including PayPal, do not natively work with Order Total discounts (mine or anyone else's).
Here are some suggestions on how to fix this:
osCommerce 2.2     osCommerce 2.3 Note that doing these integrations is your responsibility. You can try doing this before purchase by testing my Better Together or Quantity Discounts modules, both of which are free.

Buy: Buy Discount Chooser!
Pre-purchase questions? No problem! Just click here.

FAQ: click here

Configuration: Configuration of Discount Chooser is done by the built-in admin panel. You may try the admin panel for Zen Cart yourself (I don't have an osCommerce demo) using the "See it Live" instructions below. The osCommerce version is the same except that it does not include a coupon field.

Marketing Text: click here

See it Live: Go to my demo admin, and login with userid "test" password "test". Discount Chooser Admin is under the Tools menu. (Note that this is an older version of Discount Chooser, which doesn't support discounts, and of course it's Zen Cart, not osCommerce, but you will be able to get an idea of how it works.)

Add-Ons: Discount Chooser is an order total module, so the discount is not visible until the second page of checkout. If you want to see the discount on the shopping cart page (or sidebox), look at Discount Preview.

Incompatibilities: This mod builds dropdowns of all categories with products and all products in a specific category once that category is selected.

For this reason, if you have
  • over 400 categories containing products, or
  • categories with other 400 products in them,
please do not buy this software; the dropdowns will not work. You can determine how many categories you have by doing this query in phpMyAdmin:
SELECT COUNT( DISTINCT categories_id ) FROM products_to_categories;



Overview:

There are lots of discounting options in osCommerce. No one module is perfect for everyone. A lot of people wanted more power than Better Together had, but they didn't like the complexity and lack of an admin panel that came with Big Chooser. So I tried to meet them half way with Discount Chooser Mega Module.

So you're asking yourself, "What the heck is a Mega Module?" Easy. A Mega Module contains the catalog side code and an admin panel all in one. No more separate purchases, and no updating PHP code!

Discount Chooser Mega Module allows you to specify up to 12 conditions (required purchases) of products or categories, and up to 12 possible gifts. For example, the configuration below shows that if you buy product 8 and product 19, you may choose from products 16 and 12 as free (or discounted) gifts.

Note that in Discount Chooser 1.0, a discount of 100% was implicit. In version 1.1, you may specify different discounts.

Discount Chooser Admin Panel

osCommerce Discount Chooser Admin Panel

The page is broken into two areas: on the top, a list of existing discounts, and on the bottom, a form to allow you to add new linkages to create new discounts.

See it Live! If you go to my demo admin, and login with userid "test" password "test" you can see Discount Chooser Admin live. It's under the Tools menu. (This is a Zen Cart but the osCommerce admin panel looks and works the same.)

Discounts are listed in the order they were created. Discounts can currently be deleted but not edited directly; instead, to edit a discount, delete the existing one and create a new one.

Discount Chooser Discount Creation

osCommerce Discount Chooser Admin Panel

The page is broken into two areas: on the top, a list of existing discounts, and on the bottom, a form to allow you to add new linkages to create new discounts.

See it Live! If you go to my demo admin, and login with userid "test" password "test", you can try out Discount Chooser Admin. It's under the Tools menu.

The image above is what the new discount creation portion of the page looks like. Here's what the list of new discounts looks like:

Discount Chooser Discount List

osCommerce Discount Chooser Admin Panel


Discounts are listed in reverse chronological order. Discounts can currently be deleted or deactivated but not edited directly. The discounts which are currently inactive are shown in red.

Discount Chooser is an order total module, so it appears on the second page of your checkout as a discount (unless Discount Preview is used, which allows the discount to be shown in the cart).

Please note that Discount Chooser only provides a discount; it does not automatically add items to the cart.

Order Confirmation Page displaying Discount Chooser Discount

osCommerce Order Confirmation page showing Discount Chooser discount

Discount Chooser Example 1

osCommerce Discount Chooser Admin Panel

In example 1, the customer can buy a printer, and get any 3 items from mice, keyboards or CDROMs for free. So a customer could buy the printer and get 3 keyboards for free.

Discount Chooser Example 2

osCommerce Discount Chooser Admin Panel

In example 2 by contrast, the customer can buy a printer, but may only get one item from each of from mice, keyboards or CDROMs for free. So if they bought a printer and 3 keyboards, only the least expensive keyboard would be discounted.


To change this to "Buy a printer, get an item from mice, keyboards or CDROMs for half off, simply change the Discount Amount to 50.
osCommerce Discount Chooser Admin Panel


To change this to "Buy a printer, get an item from mice, keyboards or CDROMs for $10 off, simply change Discount Units to Currency Amount Off and the Discount Amount to 10.
osCommerce Discount Chooser Admin Panel


Discount Chooser Example 3

osCommerce Discount Chooser Admin Panel

Example 3 is is a classic kit discount, where the customer must buy a printer, a mouse and a keyboard in order to get a CDROM drive free.


An alternate technique for kit discounts is to set a final price for the entire kit. (Note that this technique will work best for shops which do not have embedded taxes such as a VAT; it is not recommended if you have Display Prices with Tax set to true.)

To set a final price for a group of items, you will still express the offer in terms of a discount, with the final item being the Free Gift Discounted item. Using the above example, to set a package price of $600 for the printer, mouse, keyboard and CDROM, set the Discount Units to Package Final Price and the Discount Amount to 600.
osCommerce Discount Chooser Admin Panel

The actual items will not change prices, but a discount to reduce the total price by the required amount will be created. This is most easily visualized by your customers when you have Discount Preview (with the subtotal feature) installed, as shown below.
osCommerce Discount Chooser Admin Panel

Installation Instructions:

Please see README.txt in the mod.

Installation Problems:

The most common installation problems for this module are as follows:
  1. Unfamiliarity with installing mods. Please review my Guide to Mod Installation on osCommerce.
  2. Not updating the sort orders for your order total modules.
    One method I recommend is to multiply the default values by 10, and adjust from there. For example:
    Sub-Total 10
    Shipping  20
    Discounts 21-29
    Tax       30
    Total     40
    
    Be sure the values are unique (i.e. do not use any particular number twice).
  3. Some hosts require scripts which are run from a URL - for example,
    http://your-store.com/your-admin/free_gift_chooser.php
    
    to have permissions 644. You may see a message like
    HTTP 500: Internal Server Error
    
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    
    when running Discount Chooser Admin if this is the case with your host. Simply set the permissions of admin/free_gift_chooser.php and admin/free_gift_chooser_backend.php to 644 using your FTP client (or perhaps your cPanel File Manager).
  4. If you are pulling in jQuery and/or jQueryUI already in your admin panel, you will need to comment out the require statements that do that in ./admin/free_gift_chooser.php.
  5. Did you read the incompatibilities list? You may have too many categories, for example. If this describes you but you have already bought the software, please contact me; I may be able to write some custom logic (at additional cost) to help you make this mod work.
If you are having trouble installing this module, you should also refer to my Guide to Mod Installation on osCommerce. I'm also happy to install most of my mods for a fee.

Optional Installation Instructions:

  1. I highly recommend Discount Preview with all my discounting modules. Without Discount Preview, your customers cannot see the price reductions they are entitled to until the second page of checkout (checkout confirmation). Obviously this is a disadvantage, particularly for new customers who need to go through the additional step of creating an account before they can see this information. Sometimes seeing is believing, so here's a video showing Discount Preview in action.



Notes on Taxes for osCommerce 2.3


If you don't use embedded taxes, and don't have a mix of taxable and tax-free products, and don't have a different rate of tax for shipping, please skip this section.
However, if you any of the above apply to you, please read my Notes on Taxes.



Payment Modules in osCommerce 2.2

Note: This only applies to osCommerce 2.2. For osCommerce 2.3, please click here.

Some contributed payment modules in osCommerce 2.2 (such as PayPal) are not naturally aware of the existence of discounts (mine or any other contribution or extension). For this reason, you must ensure any payment module you use takes discounts into account. Here are some guidelines:
  • If the payment module passes in a subtotal, shipping and tax, modify the subtotal (as shown below) to include the discount.
  • If the payment module passes in a shipping, tax, and total, modify the total (as shown below) to include the discount.
  • In the case of PayPal, turn OFF the sending of line item details, which will confuse PayPal since the total is not the sum of the line items. This can be done through the admin panel by setting Transaction Type to "Aggregate."
The modification involves subtracting the discount amount. If the order total is computed as follows (example taken from paypal_ipn.php):
      foreach ($order_totals as $ot) {
        $order_total[$ot['code']] = $ot['value'];
      }
then the discount is available in the $order_total variable as follows:
ModuleVariable Name
Quantity Discounts$order_total['ot_quantity_discount']
Better Together$order_total['ot_better_together']
Big Chooser$order_total['ot_big_chooser']
Big Spender$order_total['ot_bigspender_discount']
Table Discounts$order_total['ot_table_discounts']
Free Gift Chooserot_freegift_chooser.php


So for instance, subtracting the Quantity Discounts discount from a variable called $subtotal would be done as follows:
$subtotal = $subtotal - $order_total['ot_quantity_discounts'];
This would be done in process_button() for example.

Another more sophisticated approach would be to execute the order totals and use ot_total, which is the final total after discounts.
 

// BEGIN: Change to use order_totals to get values 

      $order_id = substr($cart_PayPal_IPN_ID, strpos($cart_PayPal_IPN_ID, '-')+1);
      $ord_totals = array();
      $ord_totals_query = tep_db_query("select class, value from " . TABLE_ORDERS_TOTAL . 
          " where orders_id = '" . (int)$order_id . "' order by sort_order");
      while ($totals = tep_db_fetch_array($ord_totals_query)) {
        $ord_totals[$totals['class']] = $totals['value'];
      }

// END

. . . 

      $parameters['business'] = MODULE_PAYMENT_PAYPAL_IPN_ID;
// BEGIN : use order_totals['ot_total'] for order total to include all discounts.  
      if ($ord_totals['ot_total'] > 0) {
        $parameters['amount'] = number_format($ord_totals['ot_total'], $currencies->get_decimal_places($currency));
      } else {
        $parameters['amount'] = number_format($order->info['total'] - $order->info['shipping_cost'] 
           - $order->info['tax'], $currencies->get_decimal_places($currency));
      }
// END 


Payment Modules in osCommerce 2.3

Note: This only applies to osCommerce 2.3. For osCommerce 2.2, please click here.

Some contributed payment modules in osCommerce 2.3 (2.3.1-2.3.3.x) are not naturally aware of the existence of discounts (mine or any other contribution or extension). For this reason, you must ensure any payment module you use takes discounts into account.

For some carts, PayPal Website Payments Standard has been changed to accommodate these osC discounts, but in a bizarre way. If you have
Subtotal: $30
Postage: $7.69
Discount: -$12.00
Tax (7%): $1.26
-----------------------------
Total:   $26.95
PayPal turns this into
Subtotal: $17.16
Tax (7%): $2.10
Shipping: $7.69
-----------------------------
Total:   $26.95
This is in osC 2.3.3, with no changes made to PayPal. But the final number is correct (and your actual order total figures as shown in osC admin will be correct per the checkout confirmation page).

I have seen this work on some carts and not on others depending on mods and settings; please test your own cart carefully.

PayPal Express in osCommerce 2.3 still has problems with osCommerce discounts. Here is one way to fix it:

In ./ext/modules/payment/paypal/express.php, right above the block on line 544-545 that sets the item and tax amounts:
      $params['ITEMAMT'] = $items_total;
      $params['TAXAMT'] = $tax_total;
insert the discount computation. Here's an example for Quantity Discounts. Pull in the module and its language file. Then compute the discount and add it in as a line item.
      // Add OT
      require('includes/modules/order_total/ot_quantity_discount.php');
      include(DIR_WS_LANGUAGES . $language . '/modules/order_total/ot_quantity_discount.php');
      $discount = new ot_quantity_discount();
      if ($discount->check()) {
         $qd = $discount->calculate_deductions();
         if ($qd['total'] > 0) {
            $amt = $qd['total'] * -1;
            $params['L_NAME' . $line_item_no] = 'Discount';
            $params['L_AMT' . $line_item_no] = $amt;
            $params['L_NUMBER' . $line_item_no] = 0;
            $params['L_QTY' . $line_item_no] = 1;
    
            $product_tax = 0; 
            $params['L_TAXAMT' . $line_item_no] = $paypal_express->format_raw($product_tax);
            $items_total += $paypal_express->format_raw($amt);
            $line_item_no++;
         }
      }

For other modules, here are the filenames. The object to be created is the filename without the .php suffix.
ModuleFile Name
Quantity Discountsot_quantity_discount.php
Better Togetherot_better_together.php
Big Chooserot_big_chooser.php
Big Spenderot_bigspender_discount.php
Table Discountsot_table_discounts.php
Free Gift Chooserot_freegift_chooser.php


Marketing

What good is having cross selling and upselling specials if you don't advertise them?

Discount Chooser Discounts may be automatically displayed in two places: on the product info page, and on a separate promotional page. We'll talk about the product info page first.

Customize the product_info.php file to advertise your discounts.
Add this block of code to the new copy of product_info.php:
<?php 
require(DIR_FS_CATALOG .  'freegift_chooser_marketing.php');
?>
The placement of this code is a matter of personal preference; try placing it below the product description and adjust to your tastes. It creates a message on your page that looks like what you see at the top of Discount Chooser Admin.

Buy 1 from category DVD Movies (CAT 3) , Get 1 from category DVD Movies (CAT 3) free.


Only one div block of text will be produced, with the div id freegiftChooserDiscountPolicy.

Notes on Taxes for osCommerce 2.3


If you don't use embedded taxes, and don't have a mix of taxable and tax-free products, and don't have a different rate of tax for shipping, please skip this section.
However, if you any of the above apply to you, please read my Notes on Taxes.


Major Versions

  • 1.1a 07/01/2014 - Updates to provide better support for osC 2.3.x.
  • 1.1 06/01/2014 - First release

Discount Chooser versus other Discounting Modules

Module Comparison
Better Together Better Together supports two for one offers across a category; this allows you to create a "Buy one, get one of the same item" promotion. With Discount Chooser, you can only do "Buy one, get another from the same category." (Note that the lower priced item is always the one that gets discounted in this scenario.)
Better Together supports cross sells.
Better Together requires a separate admin panel (unless you wish to use the PHP based configuration facility).
Better Together allows you to set the discount amount, but only allows 1 condition and 1 discounted item.
Big Chooser Big Chooser allows you to specify exceptions to conditions and discounts, to make discounts mutually exclusive, to make some constraints mandatory and others selectable, to constrain by price or manufacturer, to do attribute level matching, and a variety of other advanced features which are not available in Discount Chooser. However, Big Chooser is configured using a PHP API, which is may be too complex for shopowners without programming experience.
Unique to Discount Chooser
  • Discount Chooser allows you to create a final package price for a set of products. None of my other modules have this feature.


FAQ

Q: Why do I have to enable Javascript to run the Discount Chooser Admin Panel?
A: Because it uses AJAX, a Javascript based technology. This creates a faster, more responsive user interface. If you do not enable Javascript in your browser, you will see a flashing red error message at the top of the page, and the Discount Chooser Admin Panel will not operate.

Q: Why is it called Discount Chooser?
A: In the original vision and first releases, it only offered 100% discounts. I later realized it would be much more useful to permit flexible levels of discounting.

I charge a fee of $60 for the Discount Chooser Mega Module. Buy Discount Chooser.
The fee covers software only; installation is extra if you require help.