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

Zen Cart Coupon Auto Add

Zen Cart Coupon Auto Add

An upselling module for Zen Cart that automatically adds items to the customer's cart when a coupon is entered.

Coupon Auto Add is not a discounting module; it simply adds items to the cart.

Relevance: Zen Cart™ 1.3.9, 1.5.x

Current Version: 1.4 (version history)

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

Cost: $40 (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. Please use my contact form.

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

Installation Difficulty: Moderate (Some file merging)

Installation Instructions: click here

Buy: Buy Coupon Auto Add!
Pre-purchase questions? No problem! Just Please contact me with your question.

FAQ: click here

Restrictions: click here. Please read this section carefully; if you have questions, please contact me before purchasing.

Bugs: click here


Coupon Auto Add is a Zen Cart module which allows you to automatically add items to the cart. It allows you to specify a trigger coupon (the coupon which fires the Coupon Auto Add function when it is entered on the Checkout Payment page), and the item(s) to be added. Coupon Auto Add requires you to enter the coupon code and items to be added to the module itself - they are not configured through the admin panel. This sounds complicated, but it's not that bad, and many examples of common practices are provided.

Here's an example: it says when the customer enters the coupon code "FREE_24" (which is a coupon which discounts item 24 by $90.00) add an item 24 to the cart.
   function setup() { 
      $this->add_trigger_code("FREE_24");
          $this->coupon_auto_add_prod(24);
   }


When your customers enters the coupon "FREE_24"

Entering a coupon on Zen Cart payment page

then item 24 is automatically added to their cart and shows up on the Checkout Confirmation page.

Item added on Zen Cart checkout confirmation page

The calling conventions for building a Coupon Auto Add are simple: in the setup() function of includes/modules/coupon_auto_add.php add the call

$this->add_trigger_code(<coupon code>);

Then underneath this, specify the item(s) to be automatically added.
   $this->coupon_auto_add_prod(<item_to_be_added>);

The notation used to describe required purchases and items to be added is taken from my other mods and will be familiar to people who have used Better Together and friends.

For example,
$this->add_trigger_code("THANKYOU");
   $this->coupon_auto_add_prod(32);
This says, "whenever coupon THANKYOU is entered on the checkout payment page, add product 32."

Please note the following restrictions on Coupon Auto Add:
  1. Coupon Auto Add is designed to work with the standard Zen Cart checkout process. If you are using a checkout mod such as Fast and Easy Checkout or Checkout Without Account, Coupon Auto Add will not work.
  2. Items which are to be automatically added by Coupon Auto Add must meet these criteria:
    1. The item does not have attributes.
    2. The item is in stock (or you permit out of stock sales).
    3. The item does not have a Product Qty Maximum which will be exceeded by
    (Note: Products with defaultable attributes may be used, if you have installed my Default Attribute mod.)
  3. Coupon Auto Add does not remove the product if the customer does a REMOVE in the discount coupon field on the Checkout Payment page.
  4. Coupon Auto Add adds the item every time the coupon code is entered. So if a customer enters the coupon code, logs out from the checkout confirmation page, logs in later, and re-enters the coupon code, the item will be added twice.
  5. Coupon Auto Add does not recompute shipping unless the customer returns to the Checkout Shipping page.
  6. Coupon Auto Add is not a discounting module. It simply adds the product to the cart.
  7. If you are using Better Together (or any of my other discounting modules), you should consider using Discount Preview so your customers see their discounts ahead of time. Otherwise they might think you're upselling them.

Items which are set to Coupon Auto Add must be able to be added to the cart from a normal listing page. For example, if you search for the item, the search results page shows the item with "Add to Cart" functionality and not a "More Info..." link). What this means is:
  • The item does not have non-defaultable attributes.
  • The item is in stock (or you permit out of stock sales).
  • The item does not have a Product Qty Maximum which will be exceeded by adding the product to the cart.

Here are some examples

To automatically add product 11 when the "BIGSALE" coupon is entered, you would configure Coupon Auto Add like this:

function setup() { 
   $this->add_trigger_code("BIGSALE");
      $this->coupon_auto_add_prod(11);
}

The following types of parameter statements are currently supported:

  • coupon_auto_add_prod - Specifies the item to be added when the trigger is pulled
  • set_wholesale_level - indicates the auto add is only applicable to certain wholesale levels (for Dual Pricing users)

An add_trigger_code() must be done before any parameters, and a parameter applies to the add_trigger_code which directly precedes it.

Detailed Description:

Triggers and parameters are specified in the setup() function of includes/modules/coupon_auto_add.php There is no admin interface; you must modify the file directly.

Installation Instructions:

  1. Back up everything! Try this in a test environment prior to installing it on a live shop.
  2. Copy the contents of common_files to the root directory of your shop. Then copy the contents of the appropriate version-specific directory to your shop. Zen Cart 1.50 and 1.5.1 use zc150; Zen Cart 1.5.2 and 1.5.3 use zc152.
  3. Decide on the Coupon Auto Add products you wish to offer. Add them to the setup() method of includes/modules/coupon_auto_add.php
  4. Optionally, install the Default Attribute module.

Formal Syntax of Configuration

The following commands, which are specified in the setup() function of includes/modules/coupon_auto_add.php, are the mechanism for configuring a store's Coupon Auto Add items.

Coupon Auto Adds always begin by specifying an add_trigger_code. All subsequent parameters (until the next add_trigger_code) apply to this item.

add_trigger_code

Perform the following actions when a coupon with this code is entered on the checkout payment page.

$this->add_trigger_code(<coupon code>);

where:
coupon code is the code entered in the Coupon Code field under Admin > Gift Certificate/Coupons > Coupon Admin.


Parameters - coupon_auto_add_prod

The coupon_auto_add_prod() command instructs Coupon Auto Add to add the specified item after the trigger fires.

$this->coupon_auto_add_prod(<item_to_be_added>);

where:
item_to_be_added is the string PROD, followed by a product id.


Major Versions

  • 1.4 12/25/2018 - Updates for 1.5.6
  • 1.3 08/01/2016 - Updates for 1.5.5, Default Attribute
  • 1.2b 11/27/2015 - Updates for November 2015 patches for Zen Cart
  • 1.2a 11/16/2015 - Fixing merge errors
  • 1.2 01/02/2015 - Updates for Zen Cart 1.5.4
  • 1.1 07/19/2014 - Updates for Zen Cart 1.5.2 and 1.5.3
  • 1.0 10/01/2012 - First Release

Bugs

  • Versions 1.1 and 1.2 contained a merge error; this was fixed in version 1.2a.

FAQ

Q: Why do you have to add PHP code to setup()? Why didn't you put this in the Admin panel?
A: Although it's a bit tedious to have to manually code the associations, it maximizes the module's flexibility. If you need help with the setup logic, I will be happy to do it for you for a small fee, but first look at the many examples in this page.

Q: What do you mean by "defaultable attributes" or "single valued defaultable attributes?"
A: The two terms mean the same thing. They're just attributes for which a default value can be selected without needing input from the product info page. "Single valued" means the attribute has just one value. For example, a radio button with just one value (such as "PDF" or "ZIP file") is single valued. A radio button with two values (such as "red" or "green") would not be single valued. Similarly, "defaultable" means the single value can be easily set without needing additional input. For example, product with a single TEXT attribute would be single valued but not defaultable, since it's not known what the correct value would be. Similarly, a product requiring a file upload would not be defaultable.

Note that in order to take advantage of defaultable attributes, you need my Default Attribute contribution if your Zen Cart version is lower than 1.5.7. (It has been built in since Zen Cart 1.5.7.)

Q: How do I turn Coupon Auto Add off?
A: Remove all the code from the body of the setup() function. It should look like this:
  function setup() {
  } 


Q: What's the difference between Coupon Auto Add and Auto Add?
A: Auto Add adds an item to the cart when another "trigger" item is added to the cart. Coupon Auto Add adds an item to the cart when a coupon code is entered on the Checkout Payment page.

Q: All these rules and parameters and combinations make my head hurt. Will you configure this for me?
A: Naturally. Contact me with your requirements for a quote.

I charge a fee of $40 for Coupon Auto Add. Buy Now!
The fee covers software only; installation is extra if you require help.