free gift chooser

Zen Cart Free Gift Chooser Mega Module

Free Gift Chooser Mega Module for Zen Cart 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 Zen Cart Matrix-o-discounts for a perspective on Free Gift Chooser Mega Module.
A comparison to my other discounting modules is here

Relevance: Zen Cart™ 1.3.9, 1.5.x
See interoperability for changes required for Edit Orders.

You must have JavaScript enabled in your browser.

Current Version: 2.2 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 Zen Cart forum. Please email me questions instead.

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

Would you like to ask me questions before buying? No problem! Just email your inquiry to . Please be sure to include your cart type and version (e.g. Zen Cart 1.5.1) and the mod you want to buy.

Installed Cost: $120.00 (Professional installation by That Software Guy)

Installation Difficulty: Moderate

Installation Instructions: click here

Common Installation Issues: click here

Tax Notes: Notes on tax handling

Buy: Buy Free Gift Chooser! Or email your pre-purchase question to .

FAQ: click here

Configuration: Configuration of Free Gift Chooser is done by the built-in admin panel. You may try the admin panel yourself using the "See it Live" instructions below.

Marketing Text: click here

See it Live: Go to my demo admin, and login with userid "test" password "test". Free Gift Chooser Admin is under the Tools menu. (Note that this is an older version of Free Gift Chooser, which doesn't support discounts.)
If you wish to see the catalog side, go to product 166 on my demo site. Add quantity 2 to the cart; you'll see the second one is free.

Another demonstration is available; buy any gift certificate on my demo site, and you will get a free small, medium or large box.

Video: You may watch this discount being created in Free Gift Chooser v1.0 Admin panel in this video:



(Note that this is an older version which didn't support multiple types of discounting; the 100% discount was implicit. This version also did not support editing.)

You can see how to create a discount, such as buy one get one half off, in this video: Creating Discounts in Zen Cart with Free Gift Chooser.

You can see how to use the deal id feature and editing in this video: Editing Discounts in Zen Cart with Free Gift Chooser.

Promotional Page: free from my website (you must buy Free Gift Chooser separately)

Add-Ons: Free Gift 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.




Here is a sample of the Free Gift Chooser Discount promotional page, which is available for download here.

You can display your promotions on the shopping cart page and the checkout shipping page using Big Upsell.

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;
If you are using a prefix, you must include it in this statement (e.g. "FROM zen_products_to_categories" instead of "FROM products_to_categories" if your prefix is "zen_").

This module specifically sets a specific limit of 12 on both the number of items required (conditions) and number of items discounted (free gifts); you cannot use an arbitrary number the way you can in Big Chooser. You can see the dropdowns that set these two values here.

Bugs: click here


Overview:

There are lots of discounting options in Zen Cart. No one module is perfect for everyone. A lot of people wanted more power than Combination Discounts 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 Free Gift 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!

Free Gift Chooser Mega Module allows you to specify up to 12 conditions (required purchases) of products or categories, and up to 12 possible gifts or discounted items.

Free Gift Chooser Initial Screen

Free Gift 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. The bottom part is in turn broken into two parts: the conditions (if any), and the discounted items.
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 gifts.

Note that in Free Gift Chooser 1.0, a discount of 100% was implicit. In version 1.1, you may specify different discounts.
Here are the lists for the conditions and for the free gifts. As you can see, only specific numeric values (or All Products/One Each of) are permitted, so if your requirements are more complex than this, you will need to use Big Chooser and do configuration via PHP.

Free Gift Chooser Conditions Dropdown

Free Gift Chooser Gifts Dropdown


Free Gift Chooser Discount Creation

This is what the screen looks like for one possible discount.

Free Gift Chooser Admin Panel

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

Here's what the list of discounts looks like, after they have been created:

Free Gift Chooser Discount List

Free Gift Chooser Admin Panel


Discounts are listed in reverse chronological order. Discounts can currently be deleted or deactivated, and as of Free Gift Chooser version 2.0, they may be edited. The discounts which are currently inactive are shown in red.

Free Gift Chooser discounts can also be made dependant on coupons. Enter the coupon code you require at the bottom of the discount entry screen in the Coupon field.

In Zen Cart, coupons must have a value. If your coupon is not for free shipping, and you don't wish to offer a second discount with the coupon (since Free Gift Chooser will be doing the discounting), you may set the amount to $0.001. This will make the coupon check work, but then the native Uses per Coupon and Uses per Customer functionality will not work properly. You can fix this by applying my Zero Dollar Coupon changes. These are changes to includes/modules/order_total/ot_coupon.php, which must be made in order for coupons with a value of under $0.01 to work.

Another optional field is called Deal ID. If two discounts are assigned a non-zero Deal ID, only one of them will be applied. They are sorted and evaluated by the number of conditions (descending), then ID. So if you have
(6) Buy 1 Printers (CAT 5), Get 1 DVD Movies (CAT 3) free. (Deal ID: 1)  
(4) Buy 1 Graphics Cards (CAT 4), Get 1 DVD Movies (CAT 3) free. (Deal ID: 1) 
and you buy 1 printer, 1 graphics card and two DVD movies, you will only get one movie free. If you had not set the deal id field, you would get both movies free.

Free Gift 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 Free Gift Chooser only provides a discount; it does not automatically add items to the cart. If you need to automatically add your discounted items to the cart, take a look at Auto Add. (Note that several restrictions apply to Auto Add; please read the documentation carefully.)

Free Gift Chooser Discount List in Version 1.5

Free Gift Chooser Admin Panel
In version 1.5 and higher, the list of discounts has a third button, labelled with a question mark. This button shows the history of the rule: when it was first created, and if applicable, when it was last activated or deactivated. This way, if you have rules that you cycle through activating and deactivating, you can see the history of when they were updated.

Free Gift Chooser Admin Panel


Payment Page displaying Free Gift Chooser Discount

Payment page showing Free Gift Chooser discount

Free Gift Chooser Example 1

Free Gift 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.

Free Gift Chooser Example 2

Free Gift 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.
Free Gift 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.
Free Gift Chooser Admin Panel


To force a coupon requirement to get this discount, simply fill in the coupon code field with the coupon code you used when creating the coupon (in Admin->Gift Certificate/Coupons->Coupon Admin).
Free Gift Chooser Admin Panel



Free Gift Chooser Example 3

Free Gift Chooser Admin Panel

Example 3 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.

Free Gift Chooser Example 4

Here are two alternate techniques for kit discounts: package final price for the entire kit, and package percent off 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 package 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.
Free Gift Chooser Admin Panel

So the whole discount configuration would look like this:
Free Gift 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.
Free Gift Chooser Admin Panel

To set a package percent off 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 percent off of 15% for the printer, mouse, keyboard and CDROM, set the Discount Units to Package Percent Off and the Discount Amount to 15.
Free Gift Chooser Admin Panel


Free Gift Chooser Example 5

Let's do a more basic discount - buy four from a specific category, get the cheapest free. Now you can see that this discount can simply be restated as "Buy 3 from a category, get one more free," and this is indeed how you structure it in Free Gift Chooser. Let's say the category is DVD Movies. The condition is "Buy any three products" with the category set to "DVD Movies," and the discount is 100% off One DVD Movie.
Free Gift Chooser Admin Panel

Free Gift Chooser Example 6

In Free Gift Chooser 2.1, the ability to use ANY category was added. So the discount "with any purchase, get a free movie" would be implemented as shown below.
Zen Cart Free Gift Chooser Admin Panel
If the setting Admin->Modules->Order Total-> Free Gift Chooser->Repeat discounts is true, the customer would get one free movie for each item in their cart; otherwise they'd get one free movie per order.

Installation Instructions:

Upgrading Instructions:

If you are upgrading from a prior version of Free Gift Chooser Mega Module, follow these instructions rather than the installation instructions below:
  1. Unzip the file you received, and copy the contents of the unzipped admin and includes folders to the root directory of your shop. Note that the template name under includes is assumed to be "custom;" if you are using a different template name, please change file paths using "custom" to your template name instead. Note: If you are using Zen Cart 1.5.5 or higher, your template name will be "responsive_classic" if you have not changed it.

Prior to Installation:

  1. Go into Admin -> Tools -> Store Manager, and click on "Reset ALL Products Master Categories ID".

Installation

  1. Back up everything! Try this in a test environment prior to installing it on a live shop.
  2. Unzip the file you received, and copy the contents of the unzipped admin and includes folders to the root directory of your shop. Note that the template name under includes is assumed to be "custom;" if you are using a different template name, please change this prior to uploading.
  3. Run the fgc_admin.sql file against your database. You can do this in Zen Cart admin panel under Tools->Install SQL patches.
    If you are using phpMyAdmin and have used a prefix in your database, modify fgc_admin.sql to reflect this.
  4. In Admin->Modules->Order Totals, click on Free Gift Chooser and press the Install button.
  5. Free Gift Chooser may now be configured in the admin panel under Tools.
  6. If your store charges tax, be sure that the sort order for the Tax module (set in Admin->Modules->Order Total->Tax) is greater than the largest order total sort order, so that your taxes are shown after all discounts.

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 Zen Cart.
  2. A misunderstanding of "category." A category in Free Gift Chooser Mega Module is "the master category of the product, and all ancestors of that category" OR "a linked category for the product." See the Category Issues page for a discussion of the treatment of categories in my mods.
  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 Free Gift 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 the Admin panel works but you don't see discounts on the catalog side, you may not have run the adminside install. Go to Admin->Modules->Order Totals, click on Free Gift Chooser and press the Install button.
  5. If try to run the Admin Panel and get an error like
    1146 Table 'yourdb.zen_free_gift_chooser' doesn't exist
    in:
    [SELECT * FROM zen_free_gift_chooser ORDER BY id DESC ]
    If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.
    
    this means you ran the sql script in phpMyAdmin without adding the prefix manually. You can avoid this problem by running SQL scripts in Admin->Tools->Install SQL Patches.
  6. If you are granting access to Free Gift Chooser to a non-superuser in Zen Cart 1.5.x, you must make a change to a core file. In admin/includes/init_includes/init_admin_auth.php, add FILENAME_FREE_GIFT_CHOOSER_BACKEND to the list of files checked on line 49.
  7. If you wish to use coupons with Coupon Amount 0.001 (and no free shipping), then you must apply my Zero Dollar Coupon changes.
  8. 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.
  9. If you are running 1.3.9 or prior with the Admin Profiles contribution, there are a few more steps. you must install the software, then go to Admin->Tools->Admin Settings, and check 'free gift chooser' under the tools menu. Then go to Admin->Tools->Free Gift Chooser, and you'll get an error message in the form where discounts are entered. Go back to Admin->Tools->Admin Settings, and check 'free gift chooser backend'. Now Admin->Tools->Free Gift Chooser will work.
  10. Got a blank page? Review the guidelines for Debugging a blank page in Zen Cart
  11. If the line items for your order don't add up correctly, the most likely root cause is taxes. Two things to note:
    • If you use embedded taxes (i.e. Admin->Configuration->My Store->Display Prices with Taxes = True), have a mix of taxable and tax-free products, or have a different rate of tax for shipping, please read my Notes on Special Tax Situations.
    • Be sure that the sort order for the Tax module (set in Admin->Modules->Order Total->Tax) is greater than the largest order total sort order, so that your taxes are shown after all discounts. 399 is a good value for most stores.
    • To get more details on how taxes work in Zen Cart, please read my Example Description of Tax Handling.
  12. 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 Zen Cart. 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.
  2. I believe it is potentially confusing to show the shopping cart sidebox on pages which already display the shopping cart contents. Zen Cart has a built in feature to turn off the shopping cart sidebox on the shopping cart page (Go to Admin->Configuration->Layout Settings->Shopping Cart Box Status, and set this value to 2.). However, turning it off on additional pages is not difficult, and I recommend doing so. Here are the steps:
    1. If you do not have a includes/modules/sideboxes/YOUR_TEMPLATE/shopping_cart.php file, create one by copying the file includes/modules/sideboxes/shopping_cart.php.
    2. Above the line
         if ($show_shopping_cart_box == true) {
      
      add this block
           if ($show_shopping_cart_box == true) { 
              if (($current_page_base == "shopping_cart") || 
                  ($current_page_base  == "account_history_info") ||
                  ($current_page_base  == "checkout") ||
                  ($current_page_base  == "checkout_payment") ||
                  ($current_page_base  == "checkout_confirmation") 
                 ) { 
                    $show_shopping_cart_box = false;
              }
           }
      
      I did not turn the sidebox off on the checkout shipping page, but you certainly may do so by adding that as a case.


Marketing

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

Free Gift Chooser Discounts may be automatically displayed in several places: on the product info page, the shopping cart page, and on a separate promotional page. We'll talk about the product info page first.

Customize the tpl_product_info_display.php file to advertise your discounts. Copy the file includes/templates/template_default/templates/tpl_product_info_display.php into includes/templates/<YOUR_TEMPLATE>/templates
Then add this block of code to the new copy of tpl_product_info_display.php:
<?php 
require($template->get_template_dir('/tpl_freegift_chooser_marketing.php',DIR_WS_TEMPLATE, 
   $current_page_base,'templates'). '/tpl_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 Free Gift Chooser Admin, except with links instead of product or category ids. This message only shows up for discounts that are relevant to the product being viewed.

Buy 1 from category DVD Movies, Get 1 from category DVD Movies free.

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

You may also use the same block of code on your shopping cart page. Again, start by creating includes/templates/<YOUR_TEMPLATE>/templates/tpl_shopping_cart_default.php
Then add the block of code
<?php 
require($template->get_template_dir('/tpl_freegift_chooser_marketing.php',DIR_WS_TEMPLATE, 
   $current_page_base,'templates'). '/tpl_freegift_chooser_marketing.php');
?>
below the start of the page. It will show all your active Free Gift Chooser discounts.

The other available marketing vehicle is the Free Gift Chooser Discount promotional page. This page is completely optional; it is not included in the Free Gift Chooser zip archive, but it is a free download from my website for people who have purchased Free Gift Chooser. It creates a page that allows you to display all Free Gift Chooser discounts.

Notes on Taxes


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.

Be sure that the sort order for the Tax module (set in Admin->Modules->Order Total->Tax) is greater than the largest order total sort order, so that your taxes are shown after all discounts. 399 is a good value for most stores.

Running Free Gift Chooser

One tip I have for successfully operating Free Gift Chooser is to get in the habit of using Set Inactive (instead of Delete) for rules you're no longer using. This gives you a way of easily bringing them back, or comparing to your current rules.

Major Versions

  • 2.2 03/01/2017 - Make links the default in marketing text.
  • 2.1 02/05/2017 - Allow use of "any" category, updates for MySQL 5.7.
  • 2.0 01/01/2016 - Added edit feature.
  • 1.5 06/13/2015 - Added display of linkage history.
  • 1.4 04/03/2015 - Issue with final price packages when choices are used.
  • 1.3a 12/06/2014 - Fix for payment modules with their own application_top files (e.g. Paychex).
  • 1.3 10/04/2014 - Adding ability to discount packages
  • 1.2 08/01/2014 - Adding ability to use linked categories
  • 1.1 04/01/2014 - Added discounting capability
  • 1.0a 08/03/2013 - Fixed some issues which appear in newer browsers
  • 1.0 05/01/2013 - First release
  • 0.9 04/25/2013 - Beta release

Interoperability

  • If you are using Zen Cart 1.5.x and Edit Orders 4.x and Free Gift Chooser, you must make the following change:
    Create a file called admin/includes/functions/extra_functions/free_gift_chooser_lookups.php
    It should contain this code:
    <?php
    if (! function_exists('zen_get_products_manufacturers_id')) { 
      function zen_get_products_manufacturers_id($product_id) {
        global $db;
    
        $product_query = "select p.manufacturers_id
                          from " . TABLE_PRODUCTS . " p
                          where p.products_id = '" . (int)$product_id . "'";
    
        $product =$db->Execute($product_query);
    
        return $product->fields['manufacturers_id'];
      }
    }
    


Bugs

  • If you are using Free Gift Chooser 1.3 or lower, with a payment module which has its own application_top file (such as Nochex), please move
    includes/extra_configures/free_gift_chooser_tables.php
    
    to
    includes/extra_datafiles/free_gift_chooser_tables.php
    
    (The symptom you will see is that customer checkouts will fail to complete.) This issue is fixed in version 1.3a.


Free Gift 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 Free Gift 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.
Combination Discounts Free Gift Chooser allows you to require a choice of or all of up to 12 items as mandatory conditions for receiving a discount.
Combination Discounts allows you to have multiple mandatory conditions, but does not allow a choice of a subset of those items.
Combination Discounts requires a separate admin panel (unless you wish to use the PHP based configuration facility).
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 Free Gift Chooser. However, Big Chooser is configured using a PHP API, which is may be too complex for shopowners without programming experience.
Unique to Free Gift Chooser
  • Free Gift Chooser allows you to create a package final price for a set of products. None of my other modules have this feature.
  • Free Gift Chooser allows category specifications to reference linked categories (not just the master_categories_id and ancestors). Free Gift Spender is the only other of my modules to have this feature.


FAQ

Q: Why do Linked Categories only work in Free Gift Chooser/Spender?
A: The definition of a "category" in Free Gift Chooser/Spender is different from all other mods (such as Table Discounts, Big Chooser and so forth). It is "the master category of a product, and all that category's ancestors" AND "a linked category for the product." See the Category Issues page for a discussion of the treatment of categories in my mods.

Q: I'm using a category based discount and it's not working!
A: There are several possible root causes. Please see the Category Issues page for solutions.

Q: Why does using overlapping categories for my condition and discounted item not work?
A: Having overlapping category specifications for the conditions and discounting issues can cause issues. This issue (and some remedies) is discussed on this page.

Q: Do package final price discounts reduce the unit price of items?
A: No! A package final price discount simply creates a discount such that the price of the items in question minus the discount is equal to the package final price. For example, here is a demonstration of "Buy 4 movies for $100" using Free Gift Chooser, with the discount shown on the Shopping Cart page by Discount Preview.
Package Final Price Discount using Free Gift Chooser


Q: Why do I have to enable Javascript to run the Free Gift 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 Free Gift Chooser Admin Panel will not operate.

Q: Why is it called Free Gift 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 Free Gift Chooser Mega Module. Buy Free Gift Chooser.
The fee covers software only; installation is extra if you require help.