Auto Add

Zen Cart Auto Add

An upselling module for Zen Cart that automatically adds items to the customer's cart.

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

Relevance: Zen Cart™ 1.3.8, 1.3.9, 1.5.0

Current Version: 1.2 (Zen Cart 1.3.9 and 1.5.0), 1.0 (Zen Cart 1.3.8)
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.

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

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

Installation Difficulty: Moderate (Some file merging)

Installation Instructions: click here

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

See it Live: Go to this test cart. Search for the DVD "The Matrix." If you add this DVD to your cart, a $5 gift certificate will automatically be added to your cart. (Typically you will also discount the auto added item; in this case, Combination Discounts is used to discount the gift certificate.)

FAQ: click here

Auto Add is a Zen Cart module which allows you to automatically add items to the cart. It allows you to specify a trigger item (the item which fires the Auto Add function when it is added to the cart), and the item(s) to be added. Auto Add requires you to add the trigger item 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.

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

$this->add_trigger_item(<required_purchase>);

Then underneath this, specify the item(s) to be automatically added.
   $this->auto_add(<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_item(PROD, 12);
   $this->auto_add(PROD, 32);
This says, "whenever product 12 is added to the cart, add product 32."

Please note the following qualifiers on Auto Add:
  • Auto Add only adds items to the cart. It does not delete items. So in the example above, if product 12 was removed from the cart, product 32 would not be removed.
  • Auto Add is not triggered by adds from the shopping cart page. All other places where product adds can occur are supported (category listing, product info, search results, featured products, etc.) but not the shopping cart page.
  • Auto Add is not a discounting module. It simply adds the product to the cart.
  • Auto Add does not cascade. If you configure "when product 11 is added, Auto Add product 10" and "when product 10 is added, Auto Add product 20", adding product 11 will not add product 20. You must add a product 10 to get a product 20.
  • Auto Add only allows a single item to be a trigger. It does not support triggering "Buy 2 get one free" type discounts.
  • Auto Add repeats for the number of items you add. If you have a trigger on product 2 to add product 3, and you add 5 product 2's, it will auto add 5 product 3's.
  • If you are using Better Together, 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 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 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, based on Better Together discounts.

Suppose you had Better Together configured with
         $this->add_prod_to_prod(12, 11, "%", 100); 
To automatically add product 11 when product 12 is added, you would configure Auto Add like this:

function setup() { 
   $this->add_trigger_item(PROD, 12); 
      $this->auto_add(PROD, 11);
}

Similarly, if your Better Together setup was:
         $this->add_cat_to_prod(4, 11, "%", 100); 
To automatically add product 11 when a product from category 4 is added, you would configure Auto Add like this:

function setup() { 
   $this->add_trigger_item(CAT, 4); 
      $this->auto_add(PROD, 11);
}
The following types of parameter statements are currently supported:

  • add_trigger_item - specifies the item which triggers the Auto Add
  • auto_add - Specifies the item to be added when the trigger is pulled

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

Detailed Description:

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

Note that CAT has the Big Chooser/Big Spender/Combination Discounts semantics, not the Better Together ones. In Better Together, CAT only includes items directly below the specified category (i.e. CAT means "parent category" based on the master_categories_id field in the products table). In Auto Add, CAT includes all items below the specified category, whether they are directly below or in subcategories.

Men's Clothing (category 3)
     |
     ---->  Shirts (category 5)
     |      |
     |      -------> shirt A 
     |               shirt B
     |               shirt C 
     ---->  Pants (category 6)
     |      |
     |      -------> pants A 
     |               pants B
     |               pants C 
     ---->  Shoes (category 7) 
            |
            --->  Dress Shoes (category 12) 
            |     |
            |     -------> dress shoes A 
            |              dress shoes B
            |              dress shoes C 
            --->  Casual Shoes (category 18) 
                  |
                  -------> casual shoes A 
                           casual shoes B
                           casual shoes C 

Specifying "Men's Clothing" as a category in Auto Add will include all items in Shirts, Pants and Shoes.

Specifying "Shoes" (CAT 7) as a category will include both dress shoes and casual shoes. This cannot be done in Better Together.

Note that "parent category id" is determined using the master_categories_id field from the products table. So if casual shoes A is also linked into a category called "Hot Products," the parent category is still category 18 (Casual Shoes). For more details on category handling in Auto Add, please see the Category Issues page.

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 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.
  3. Decide on the Auto Add products you wish to offer. Add them to the setup() method of includes/modules/auto_add.php.

Formal Syntax of Configuration

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

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

add_trigger_item

Perform the following actions when an item matching the trigger is added to the cart.

$this->add_trigger_item(<required_purchase>);

where:
required_purchase is the string PROD, CAT, or MANUF, followed by an identifier (product or category id, or manufacturer id)


Parameters - auto_add

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

$this->auto_add(<required_purchase>);

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


Major Versions

  • 1.2 11/06/2011 - Updated for Zen Cart 1.5.0 (no functional changes)
  • 1.2 09/24/2011 - Updated to latest shopping_cart.php file in 1.3.9.
  • 1.1 03/09/2011 - Added set_wholesale_level for Dual Pricing users.
  • 1.0 04/25/2010 - Updated to 1.3.9
  • 1.0 03/01/2010 - First Release (Zen Cart 1.3.8)

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: How do I turn Auto Add off?
A: Remove all the code from the body of the setup() function. It should look like this:
  function setup() {
  } 


Q: When I use PROD, it works, but I can't seem to get CAT to work. Why?
A: The CAT value you specify is matched against the master_categories_id field in the products table. Sometimes this value is not what you expect it to be, either because of a database upgrade or because you're using linked categories. Please see the Category Issues page for solutions.

Q: What's the difference between Auto Add and Buy Both Now?
A: Buy Both Now allows you to have a single button add for two items with a prod_to_prod linkage in Better Together. However, both items must have have attributes. With Auto Add, you can have as the trigger an item which has attributes, and have as the Auto Add an item which does not, and you will get the same "one click buy" functionality.

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 Auto Add. The fee covers software only; installation is extra if you require help.



Want more Zen Cart?     Tips and Tricks     Contributions     Extensions     Custom Software     Newsletter

Terms | Privacy | SiteMap | Newsletter | Contact Me | Contents © 2003-2011 That Software Guy, Inc.
Zen Cart Project Home Page | Zen Cart Forum | Zen Cart™ is © Zen Ventures, LLC.