Zen Cart Newsletter Discount
Newsletter Discount is a Zen Cart™ discounting module which allows you to offer reduced prices for newsletter subscribers. It can be configured to work with the native Zen Cart newsletter facility or with MailChimp.Donate: This is free software. Show your appreciation by supporting my efforts.
Relevance: Zen Cart™ 1.3.5 - 1.3.9, 1.5.x
Current Version: 4.3 (MailChimp API 3.0)
Please check the version history to ensure the feature you want is available in your version.
Note: After 12/31/16, only version 3.0 of the API will be supported. You must update.
Support Thread: Newsletter Discount Support Thread
Cost: Free, but donation appreciated
Installed Cost: $100 Buy Professional Installation by That Software Guy
Installation Instructions: click here
Location: Zen Cart Plugins, under Pricing Tools.
Download: Newsletter Discount in Zen Cart Plugins
FAQ: click here
Add-Ons: For MailChimp users, the MailChimp Integration contribution interoperates with Newsletter Discount.
Overview:
Newsletter Discount allows you to offer a percentage discount on purchases made by someone who has signed up for your newsletter.Newsletter Discount is an order total module; it only shows up on the second page of checkout.
Payment Page displaying Newsletter Discount
Installation Instructions:
- Back up everything! Try this in a test environment prior to installing
it on a live shop.
If you have installed this module before, go to Admin > Modules > Order Total > Newsletter Discount, note your settings, and press "remove" to uninstall the module. - Copy the contents of the unzipped folder to the root directory of your
shop.
The names of these files reflect a template name of "custom." If you are using a different template name, please change file paths using "custom" to use 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. - Login to Admin and in Modules > Order Total you will see 'Newsletter Discount' listed along with all the other modules available.
- Click on 'Newsletter Discount' to highlight the module and click on 'Install'
- If you are using MailChimp, login to your MailChimp account. At the top of the MailChimp page is a dropdown called "Account." Select "API keys & info" and add an API key to your account. This is the value you should enter in the "API Key" field in Newsletter Discount config.
- Set the parameters according to your discounting plan.
- If you wish, follow the guidelines in marketing to advertise your discounts.
Configuration:
Some shops will want to further customize their discounting policy. User exits are provided to permit the following customizations:- Include or exclude certain categories from discounting.
- Include or exclude certain products from discounting.
Specifically:
- The function exclude_category() shows you how to add categories to a list of categories to not be discounted.
- The function exclude_product() shows you how to add products to a list of products to not be discounted.
Each of these functions contains a simple example of how to use it using item and category numbers like 99999, 99998, etc. Note that the "category" of an item is its parent category; see my category explanation page for an explanation. Note that to use the category exclusions you must be running Zen Cart 1.3.5 or greater.
The user exits are in
includes/modules/order_total/ot_newsletter_discount.php
MailChimp
MailChimp is an Email Service Provider; their business is managing commercial email. They have a very reasonable per-email cost model (unlike firms like Constant Contact, which charge per month irrespective of how little mail you send). You can integrate MailChimp into your Zen Cart using the MailChimp Newsletter contribution.The Newsletter Discount contribution uses the MailChimp API to communicate with MailChimp and determine whether the customer is a newsletter subscriber.
Configuration of Newsletter Discounts when using MailChimp:
- In Admin > Modules > Order Total > Newsletter Discount, You must
set the Newsletter Type to
mailchimp
and fill in the MailChimp API Key. - By default, all MailChimp lists you have set up are scanned.
If you want to use one list only, look for the line
$id = $lists[$i]['id'];
and change it toif ($lists[$i]['name'] != 'Your-Newsletter-List-Name') continue; $id = $lists[$i]['id'];
Change Your-Newsletter-List-Name to the actual name of your list
Marketing
A discounting plan reaches maximum effectiveness through advertising.Customize the tpl_product_info_display.php file to advertise your discounts. Put the file
includes/templates/template_default/templates/tpl_product_info_display.php
into
includes/templates/<YOUR_TEMPLATE>/templates
,
and add this block
of code to the page:
<?php $value = "ot_newsletter_discount.php"; include_once(zen_get_file_directory(DIR_WS_LANGUAGES . $_SESSION['language'] . '/modules/order_total/', $value, 'false')); include_once(DIR_WS_MODULES . "order_total/" . $value); $discount = new ot_newsletter_discount(); echo '<div class="content" id="discountPolicy">'; $resp = $discount->get_html_policy(); echo $resp; echo '</div>'; echo '<br class="clearBoth" />'; ?>The placement of this code is a matter of personal preference; try placing it below the product description and adjust to your tastes.
You can put this code wherever you'd like. For example, here I have placed it in tpl_modules_create_account.php so that new signups see the policy when making their newsletter choice:
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.
Files
All files are new.
includes/languages/english/modules/order_total/ot_newsletter_discount.php
includes/modules/order_total/ot_newsletter_discount.php
includes/functions/extra_functions/mailchimp_discount_functions.php
includes/functions/extra_functions/mailchimp.php
Learning More about Newsletters
MailChimp provides some excellent resources to help you learn about newsletters, whether or not you use their service. Start with MailChimp Email Marketing Guide. Then take a look at their Resource Center.To learn more about the value proposition of the MailChimp service, go to their features and benefits page.
Major Versions
- 4.3 05/12/2023 - Updates for 1.5.7
- 4.2 11/15/2018 - API Integration issues.
- 4.1 03/01/2017 - Dollars off/order, cache MailChimp subscriber status.
- 4.0b 02/19/2017 - Fixed a bug in subscriber check
- 4.0a 11/06/2016 - Fixed bug report on forum.
- 4.0 10/23/2016 - Update to new MailChimp API 3.0
- 3.0 05/01/2012 - Update to new MailChimp API 1.3
- 2.0 08/01/2010 - Update to new MailChimp API 1.2
- 1.3 11/13/2008 - Resolve issue with PayPal IPN.
- 1.2 08/25/2008 - Upgrade to version 1.1 of MailChimp API.
- 1.1 06/01/2008 - Adding ways to customize the order total calculation; upgrade to version 1.0 of MailChimp API
- 1.0 04/02/2008 - First Release
FAQ
Q: I'm using exclude_category() and it's not working!A: Please see the Category Issues page for solutions.
Q: I do not want to discount products 12 and 13. How do I do this?
A: Update the function exclude_product() in
includes/modules/order_total/ot_quantity_discount.php
as follows:
function exclude_product($prid) { $id = (int)$prid; switch($id) { case 12: case 13: return true; } return false; }
Q: I only want discounts applied to items in category 11. How do I do this?
A: Update the function exclude_category() in
includes/modules/order_total/ot_newsletter_discount.php
as follows:
function exclude_category($category) { switch($category) { case 11: return false; } return true; }
Q: I don't want discounts applied to items in category 7. How do I do this?
A: Update the function exclude_category() in
includes/modules/order_total/ot_newsletter_discount.php
as follows:
function exclude_category($category) { switch($category) { case 7: return true; } return false; }
Q: If I use exclude_category() or exclude_product(), what changes do I need to make so the marketing text reflects this?
A: For category exclusions, change tpl_product_info_display.php from
if ($discount->check() > 0) {to
if ( ($discount->check() > 0) && (!$discount->exclude_category($current_category_id)) ) {For product exclusions, use
if ( ($discount->check() > 0) && (!$discount->exclude_product($_GET['products_id'])) ) {Another more detailed example is given here.