free gift spender

Zen Cart Free Gift Spender Mega Module

Free Gift Spender Mega Module for Zen Cart simplifies the process of creating discounts based on dollars spent. It's almost like Big Spender with an Admin panel!

Background: See the Zen Cart Matrix-o-discounts for a perspective on Free Gift Spender 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: 1.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 Spender! Or email your pre-purchase question to .

FAQ: click here

Configuration: Configuration of Free Gift Spender is done by the built-in admin panel.

Marketing Text: click here

Video: Several discounts are created and demonstrated in this video:



The Discount Preview in Zen Cart video also shows an example of using Free Gift Spender.

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

Add-Ons: Free Gift Spender 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 Spender 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 the number of items discounted (free gifts); you cannot use an arbitrary number the way you can in Big Spender. You can see the dropdown that sets this value here.


Overview:

There are lots of discounting options in Zen Cart. No one module is perfect for everyone. A lot of people wanted the power of Big Spender. but they wanted an admin panel. So I tried to meet them half way with Free Gift Spender 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 Spender Mega Module allows you to specify a dollar threshold (which may be drawn from particular categories, and exclude other categories), and up to 12 possible gifts or discounted items.

Free Gift Spender Initial Screen

Free Gift Spender 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 and negative conditions (if any), and the discounted items.

Here is the list 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 Spender and do configuration via PHP.

Free Gift Spender Gifts Dropdown


Free Gift Spender Discount Creation

The configuration below shows that if you spend over $100, you may choose from products 16 and 12 as free gifts.

Free Gift Spender Admin Panel



Once the Submit button is pressed on the screen shown in the image above, a new discount is created and placed into a list at the top of the screen. Here's what the list of discounts looks like, after they have been created:

Free Gift Spender Discount List

Free Gift Spender Admin Panel


Discounts are listed in reverse chronological order by default, but the order can be changed to by deal id, which is convenient if you have tiered discounts. (An example of a tiered discount is, "Spend $100, get A and B; spend $50, get A.") Discounts can be edited, deleted or deactivated. The discounts which are currently inactive are shown in red. The list of discounts also has a 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 Spender Admin Panel


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

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

Payment Page displaying Free Gift Spender Discount

Payment page showing Free Gift Spender discount

Free Gift Spender Example 1

Free Gift Spender Admin Panel

In example 1, the customer can spend $400 on printers, 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 Spender Example 2

Free Gift Spender Admin Panel

In example 2 by contrast, the customer can spend $400 on printers, 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 Spender 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 Spender 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 Spender Admin Panel



Free Gift Spender Example 3a Tiered Discounts

Free Gift Spender Admin Panel

Example 3a shows a tiered discount with overlapping condition categories. The condition categories are the same, so both discounts would be given for spending $200 or more. (In other words, someone spending $200 or more would be able to get four DVD movies free.) Since this may not be the behavior you want, a couple of options are shown below.

Free Gift Spender Example 3b Tiered Discounts with Deal ID

Free Gift Spender Admin Panel

Example 3b shows a tiered discount with overlapping condition categories, but each discount has a deal id set to 1. When discounts have a non-zero deal id, only one of the discounts (the highest value one) will apply. So in this case, someone spending $200 or more would be eligible for 3 DVD movies.

Free Gift Spender Example 3c Tiered Discounts with Different Conditions

Free Gift Spender Admin Panel

Example 3c shows a tiered discount with non-overlapping condition categories, So in this case, to get all 4 DVD movies, someone would have to spend $200+ on Hardware and $100+ on Software.

Installation Instructions:

Upgrading Instructions:

If you are upgrading from a prior version of Free Gift Spender 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 this prior to uploading.

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 file paths using "custom" to use your template name instead.
  3. Run the fgs_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 fgs_admin.sql to reflect this.
  4. In Admin->Modules->Order Totals, click on Free Gift Spender and press the Install button.
  5. Free Gift Spender 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 Spender 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_spender.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 Spender Admin if this is the case with your host. Simply set the permissions of admin/free_gift_spender.php and admin/free_gift_spender_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 Spender and press the Install button.
  5. If try to run the Admin Panel and get an error like
    1146 Table 'yourdb.zen_free_gift_spender' doesn't exist
    in:
    [SELECT * FROM zen_free_gift_spender 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 Spender 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_SPENDER_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_spender.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 Spender' under the tools menu. Then go to Admin->Tools->Free Gift Spender, 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 Spender backend'. Now Admin->Tools->Free Gift Spender 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.


Discount Configuration

  • The order of execution of discounts is in order of deal id (DESCENDING), then in the order of spend condition (DESCENDING). If no deal ids are set (i.e. they are all 0), execution will be in descending order of spend condition.
  • The order of granting a free or discounted gift will be in the order specified during discount creation, then by price in ascending order.
    • In the Discount Creation Screen example, (Spend $100, choose from product 16 or product 12 free) If the customer spent $100, and had both product 16 and product 12 in their cart, then product 16 would be discounted, since it appeared first in the list.
    • In example 3c, (Spend $100 on software, get 1 DVD movie free) if the customer was buying $100 of software, along with one movie for $35, and one movie for $19, it would be the $19 movie which would be discounted.
  • As is shown in example 3a and example 3b, you may wish to exclude the discounted category from being counted when no other category conditions exist. If this was not done, then the discounted item would be counted towards the spend, which may not be your intention.

Marketing

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

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

Customize the tpl_shopping_cart_default.php file to advertise your discounts. Copy the file includes/templates/template_default/templates/tpl_shopping_cart_default.php into includes/templates/<YOUR_TEMPLATE>/templates
Then add this block of code to the new copy of tpl_shopping_cart_default.php:
<?php 
require($template->get_template_dir('/tpl_freegift_spender_marketing.php',DIR_WS_TEMPLATE, 
   $current_page_base,'templates'). '/tpl_freegift_spender_marketing.php');
?>
The placement of this code is a matter of personal preference; try placing it below the subtotal and adjust to your tastes. It creates a message on your page that looks like what you see at the top of Free Gift Spender Admin, except with links instead of product and category ids.

(1) Spend $50.00 in any category, Get 1 Comedy free.

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

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

One tip I have for successfully operating Free Gift Spender 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

  • 1.2 03/01/2017 - Make links the default in marketing text.
  • 1.1 02/05/2017 - Updates for MySQL 5.7
  • 1.0 10/01/2015 - First release

Interoperability

  • If you are using Zen Cart 1.5.x and Edit Orders 4.x along with Free Gift Spender, you must make the following change:
    Create a file called admin/includes/functions/extra_functions/free_gift_spender.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'];
      }
    }
    


Free Gift Spender versus other Discounting Modules

Module Comparison
Big Spender Big Spender 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 Spender. However, Big Spender is configured using a PHP API, which is may be too complex for shopowners without programming experience.
Unique to Free Gift Spender
  • Free Gift Spender allows category specifications to reference linked categories (not just the master_categories_id and ancestors). This feature is unique to Free Gift Spender and Free Gift Chooser.
  • Free Gift Chooser has an edit feature for previously created discounts. None of my other modules have this.


FAQ

Q: Why do Linked Categories only work in Free Gift Spender/Chooser?
A: The definition of a "category" in Free Gift Spender/Chooser is different from all other mods (such as Table Discounts, Big Spender 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: Why do I have to enable Javascript to run the Free Gift Spender 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 Spender Admin Panel will not operate.

Q: Why is it called Free Gift Spender?
A: It corresponds to Free Gift Chooser, a product based discounting tool. In the original vision of Free Gift Chooser, only 100% discounts were possible. I later realized it would be much more useful to permit flexible levels of discounting. So the name is a bit confusing, but for the sake of symmetry, I kept it.

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