Zen Cart Discount Spender Mega Module
Discount Spender Mega Module for Zen Cart (formerly Free Gift Spender) 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 Discount Spender Mega Module.
A comparison to my other discounting modules is provided.
Example Discounts: I have provided several examples of Zen Cart Discount Spender discounts.
Relevance: Zen Cart™ 1.5.x
See interoperability for changes required for Edit Orders.
You must have JavaScript enabled in your browser.
Current Version: 1.5. (version history)
Support Thread: My commercial software is not supported on the Zen Cart forum. Please email me questions instead.
Cost: $60 (Note: this low price covers software only for self-installation.)
Would you like to ask me questions before buying? I'm happy to help likely purchasers make the right decision. Please use my contact form.
Installed Cost: $200.00 (Professional installation by That Software Guy)
Installation Difficulty: Moderate
Installation Instructions: click here for installation instructions
Common Installation Issues: click here for installation issues
Tax Notes: Notes on tax handling
Buy: Buy Discount Spender!
Pre-purchase questions? No problem! Just Please contact me with your question.
FAQ: click here for FAQ
Configuration: Configuration of Discount Spender is done by the built-in admin panel.
Marketing Text: click here for marketing text
Video: Several discounts are created and demonstrated in this video:
The Discount Preview in Zen Cart video also shows an example of using Discount Spender.
Promotional Page: free from my website (you must buy Discount Spender separately)
Add-Ons: Discount 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.
You can display your promotions on the shopping cart page and the checkout shipping page using Big Upsell.
The promotional page for Discount Spender 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,
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 in the dropdown section here.
Bugs: click here for bugs
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 Discount 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!
Discount 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.
Discount Spender Initial Screen
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.
Dropdown
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.Discount Spender Discount Creation
The configuration below shows that if you spend over $100, you may choose from products 16 and 12 as free gifts.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:
Discount Spender Discount List
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.
Discount Spender discounts can also be made dependent 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 Discount 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.
Discount 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 Discount 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 Discount Spender Discount
Discount Spender Example 1
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.
Discount Spender Example 2
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.
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.
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).
Discount Spender Example 3a Tiered Discounts
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.
Discount Spender Example 3b Tiered Discounts with Deal ID
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.
Discount Spender Example 3c Tiered Discounts with Different Conditions
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.
How Discounts are Selected
The basic operation of all my "Buy X, Get Y at a discount" modules is the same:- sort from most expensive to least;
- pick off the most expensive matching item(s) for the condition (the item(s) which must be purchased to get the discount)
- pick off the least expensive matching item(s) to discount
- remove the matching items from further consideration by this module (unless some sort of override exists)
Discount Spender chooses conditions and discounting items using the same rules as Discount Chooser.
Installation Instructions:
Upgrading Instructions:
If you are upgrading from a prior version of Discount Spender Mega Module, follow these instructions rather than the installation instructions below:- 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:
- Go into Admin > Tools > Store Manager, and click on "Reset ALL Products Master Categories ID".
Installation
- Back up everything! Try this in a test environment prior to installing it on a live shop.
- 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.
- 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. - In Admin > Modules > Order Total, click on Discount Spender and press the Install button.
- Discount Spender may now be configured in the admin panel under Tools.
- 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:- Unfamiliarity with installing mods. Please review my Guide to Mod Installation on Zen Cart.
- A misunderstanding of "category." A category in Discount 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.
-
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 Discount 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). - If the Admin panel works but you don't see discounts on the catalog side, you may not have run the admin side install. Go to Admin > Modules > Order Total, click on Discount Spender and press the Install button.
-
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. - If you are granting access to Discount 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. - If you wish to use coupons with Coupon Amount 0.001 (and no free shipping), then you must apply my Zero Dollar Coupon changes.
- 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.
- 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 'Discount Spender' under the tools menu. Then go to Admin > Tools > Discount Spender, and you'll get an error message in the form where discounts are entered. Go back to Admin > Tools > Admin Settings, and check 'Discount Spender backend'. Now Admin > Tools > Discount Spender will work.
- Got a blank page? Review the guidelines for Debugging a blank page in Zen Cart
-
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.
- If you are upgrading from a very old copy of this mod, you may need
to rerun the table creation script, since the tables have changed.
Note your current discounts and then go to
Admin > Tools > Install SQL Patches and run
fgs_admin.sql
. Then re-add your discounts. - 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.
Optional Installation Instructions:
- 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.
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?Discount 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 Discount 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 Discount Spender Discount promotional page. This page is completely optional; it is not included in the Discount Spender zip archive, but it is a free download from my website for people who have purchased Discount Spender. It creates a new page for your site that allows you to display all your discounts.
This new page can be accessed via the URL
YOURSITE.com/index.php?main_page=freegiftspender_promoA link to this page may be added to the categories sidebox, the site footer, or the main page content for your site. See Promotional Pages for more information and ideas.
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 Discount Spender
One tip I have for successfully operating Discount 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.5 02/12/2022 - PHP 8 updates
- 1.4 06/04/2021 - Updates for Zen Cart 1.5.7 / newer MySQL versions.
- 1.3 12/21/2018 - PHP7 updates.
- 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
Discount Spender,
you must make the following change:
Create a file calledadmin/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']; } }
Bugs
-
For recalculate tax = Standard, carts using Edit Orders 4.3.1 will need to change the process() function
in the code file in
includes/modules/order_total
as follows:
Changeif ($this->calculate_tax != 'VAT') { $order->info['total'] -= $od_amount[$key]; }
toif (!IS_ADMIN_FLAG) { if ($this->calculate_tax != 'VAT') { $order->info['total'] -= $od_amount[$key]; } }
Discount 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 Discount Spender. However, Big Spender is configured using a PHP API, which is may be too complex for shopowners without programming experience. |
Unique to Discount Spender |
|
FAQ
Q: Why do Linked Categories only work in Discount Spender/Chooser?A: The definition of a "category" in Discount 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: Where's Checkout Candy for Discount Spender?
A: The complexity of the specification mechanism for Discount Spender makes it very difficult to create a workable Checkout Candy algorithm. Instead, I created Big Upsell.
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 Discount 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 Discount Spender Admin Panel will not operate.
Q: Why is it called Discount Spender?
A: It corresponds to Free Gift Spender, a product based discounting tool. In the original vision of Free Gift Spender, 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 Discount Spender Mega Module.
Buy Discount Spender.
The fee covers software only; installation is extra if you require help.
The fee covers software only; installation is extra if you require help.