better together

Zen Cart Better Together

A Zen Cart™ discounting module allowing vendors to promote related items.

Donate! Show your appreciation by supporting my efforts.

Background: See the Zen Cart Matrix-o-discounts

Relevance: Zen Cart™ 1.3.5 and forward

Be sure to see the rest of the Better Together World.

Cost: Free, but donation appreciated

Location: Zen Cart Downloads page, under Marketing Tools

Download: Better Together On Zen Cart Downloads Page

Promotional Page: information here.

Current Version: 2.1
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: Better Together Support Thread

FAQ: click here

Installation: click here

Marketing Text: click here

See it Live: Go to product 12 in my demo shop you will see the upsell message for product 14. (The converse is also true.)

The code that created this Better Together linkage was:
   function setup() { 
         $this->add_prod_to_prod(14, 12, "%", 50);
   }


Add-Ons:
The add-ons for Better Together are all grouped together on one page called The Better Together World.

The Better Together Admin panel (a separate product which is sold as commercial software) allows you to create discounts without needing to edit files.

If you add product 12 to your cart, you will notice that on the shopping cart page (and the first checkout page) that Checkout Candy re-enforces the upselling message.

You can see Better Together with Buy Both Now by looking at product 3 in my demo shop.

If you add both these products to your cart, you will be able to see the discount in your cart because of Discount Preview.

The Better Together Promotional Page allows you to display all your Better Together discounts on one page. Here is a sample of the Better Together Discount promotional page. You can even do a single-click add for two product discounts with no attributes on the Promotional Page using the Add both to Cart.

The Better Together Offers on Listing Pages extension displays the marketing text for your Better Together offers on listing pages such as All Products, Search Results and Manufacturer Pages.

Bugs: click here

osCommerce User? This is a Zen Cart page. Look at the Better Together for osCommerce World for osCommerce help.

Overview:

The gold standard of online retailing is Amazon.com. Zen Cart store operators looking to increase their profitability should constantly be asking, "WWAD?" or "What would Amazon do?"

When you look at an item in Amazon, not only is a cross selling recommendation made, a discount is offered to persuade the customer to accept the recommendation. This mod permits you to offer this type of discounted cross selling in your Zen Cart.

You may specify
  • Buy item X, get item Y at a discount
  • Buy item X, get an item from category A at a discount
  • Buy an item from category A, get an item from category B at a discount
  • Buy an item from category A, get item X at a discount

Discounts may be specified as percentages of the latter item's price or as absolute values in the currency your cart uses.

These discount specifications are called "linkages," because they "link" one product or category to another. These linkages are not only used in discount calculations; they are also used to create messages which are automatically displayed on the product_info page. Details on how to do this are provided in marketing.

In addition, Better Together may be used to facilitate two-for-one offers for identical items. Although it may be argued that this is simply a special case of "buy item X, get item Y at a discount," this capability was added to facilitate two for one offers for an entire category of goods with a single statement. You may specify two-for-one type specials such as
  • Buy item X, get another item X free
  • Buy an item from category A, another identical item free
Better Together 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 Better Together only provides a discount; it does not automatically add items to the cart.

Payment Page displaying Better Together Discount

Payment page showing Better Together discount

Detailed Description:

The original model for adding Better Together discounts was that people would modify the setup() function at the bottom of the file
includes/modules/order_total/ot_better_together.php  

This still works, but now another available option is the Better Together Admin panel (a separate module which is sold commercially). Better Together Admin is easy to use and fast - and it's a great way to show your support for Better Together.

If you wish to continue editing the setup function, several examples are provided.
Four types of linkages may be performed. The format of each of these is the same:
  • first identifier (product or category)
  • second identifier (product or category)
  • "%" or "$" to indicate how discounting is to be done
  • a number, indicating the discount amount.
The four calls for the four types of discounting are
  • add_prod_to_prod()
  • add_prod_to_cat()
  • add_cat_to_cat()
  • add_cat_to_prod()
If a straight two for one discount is what is desired, the calls are
  • add_twoforone_prod()
  • add_twoforone_cat()
Let's consider two products: product 5 from category 3, and product 2 from category 1.

Suppose you want to offer a 50% discount on product 5 with the purchase of product 2. Make the setup() function look like this:
   function setup() { 
      $this->add_prod_to_prod(2,5,"%", 50); 
   }

Want to make it buy product 2, get product 5 free?
   function setup() { 
      $this->add_prod_to_prod(2,5,"%", 100); 
   }

How about buy one product 2, get one free?
   function setup() { 
      $this->add_prod_to_prod(2,2,"%", 100); 
   }

Remember product 5 is in category 3. If instead of specifying product 5 in particular, you want to discount any item in category 3 by 20% with the purchase of a product 2 item, use
   function setup() { 
      $this->add_prod_to_cat(2,3,"%", 20); 
   }

Discount can be done in currencies as well. To offer $7 (or 7 of whatever currency your cart uses), use
   function setup() { 
      $this->add_prod_to_cat(2,3,"$", 7); 
   }

(The "$" is just used to specify currency; your cart's currency settings will be respected when computing the discount.)

Remember product 2 is in category 1. If you want to widen the discount to provide a discount of 20% off any item in category 3 when an item from category 1 is purchased, use
   function setup() { 
      $this->add_cat_to_cat(1,3,"%", 20); 
   }

Any number of these discounts may be offered; discount computation will be done in the order in which your discounts are specified in setup(), and items will be processed in the order in which they appear in the cart.

Using the examples above, suppose these items are in your cart:

1 - Product 2, category 1
2 - Product 10, category 1
2 - Product 20, category 3
2 - Product 5, category 3

and suppose you have coded these discounts:
   function setup() { 
      $this->add_prod_to_prod(2,5,"$", 7); 
      $this->add_cat_to_cat(1,3,"%", 25); 
   }

The following discounts will be computed:
  • $7 off ONE product 5 because of ONE product 2 (rule 1)
  • 25% each off TWO product 20 because of TWO product 10 (rule 2)
To get $7 off the second product 5, the customer would need to add a second product 2 to the cart.

With the same cart, coding
   function setup() { 
      $this->add_cat_to_cat(1,3,"%", 25); 
      $this->add_prod_to_prod(2,5,"$", 7); 
   }

Would compute the following discount:
  • 25% off ONE product 20 because of ONE product 2 (rule 1)
  • 25% off ONE product 20 because of ONE product 10 (rule 1)
  • 25% off ONE product 5 because of ONE product 10 (rule 1)
Obviously these could be very different discounts!

To create a two for one discount for product 5, simply code
   function setup() { 
      $this->add_twoforone_prod(5);
   }
And to create two for one discount for all products in category 3, code
   function setup() { 
      $this->add_twoforone_cat(3);
   }


Note the difference between
   function setup() { 
      $this->add_twoforone_cat(3);
   }
and
   function setup() { 
      $this->add_cat_to_cat(3,3,"%", 100); 
   }
The latter says, "buy any item from category three, and get 100% off any other item from category three." The former says, "all items in category three are buy one, get an identical item free." So if a customer bought items 20 and 30 from category three, a discount would only be given in the latter case.

To make these discounts visible on your product info page, customize the file includes/templates/template_default/templates/tpl_product_info_display.php as described in marketing below in the installation instructions. This step will create text like this:

Buy this item, get a Microsoft Intellimouse Explorer at 50% off
Buy this item, get an item from Memory at 50% off

The link is created to facilitate the cross-sell. This step is optional; if you prefer, you can add your own cross-selling text.

Category Handling

Note that the "category" in add_cat_to_cat(), add_prod_to_cat(), add_cat_to_prod() and add_twoforone_cat() is the parent category, as determined by the master_categories_id field in the products table. If subcategories are being used, the parent category will not be the same as the top level category. If the product is linked to another category, the parent category will still be the original parent category (the master_categories_id field).

Men's Clothing  (Category 7)
     |
     ---->  Shirts (Category 12)
            |
            -------> shirt A 
                     shirt B
                     shirt C 
In this example, the parent category of "shirt A" is "Shirts," not "Men's Clothing." "Mens' Clothing" would be considered the top level category.

In stores where the first level of categories has products directly underneath it, the top level category and the parent category are the same.

If your store uses subcategories and you require the ability to reference categories at different levels, you may wish to consider purchasing either Combination Discounts or Big Chooser.

Again, note that "parent category id" is determined using the master_categories_id field from the products table. So if Shirt A is also linked into a category called "Hot Products," the parent category is still category 12 (Shirts). For more details on category handling in Better Together, 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. If you already have the Better Together module installed, please deinstall your old copy by going to Admin->Modules->Order Total, selecting "Better Together" and pressing the "Remove" button. Make a note of your settings so you can apply them to the new version.
  3. 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.
  4. Login to admin and in Modules->Order Total you will see 'Better Together' listed along with all the other modules available.
  5. Click on 'Better Together' to highlight the module and click on 'Install'
  6. Decide on the linkages you wish to use, and add them to the setup() function in includes/modules/order_total/ot_better_together.php. Open a shopping cart in another window to test these discounts. They are shown on the second step of checkout in "Your Total" under "Better Together."
  7. If you wish, follow the guidelines in marketing
  8. If you wish, install the Better Together Promotional Page (which displays all your Better Together discounts on one page).
  9. Donate! Show your appreciation by supporting my efforts.


Installation Problems:

The most common installation problems for this module are as follows:
  1. For Better Together Admin Panel users: Forgetting to modify includes/modules/order_total/ot_better_together.php as described in the Better Together Admin Panel instructions.
  2. Using a category function - add_prod_to_cat() or add_cat_to_cat() or add_twoforone_cat() - can cause problems - see the Category Issues page.
  3. Not donating often causes problems. Donate! Show your appreciation by supporting my efforts.
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.

Marketing

Donate! Show your appreciation by supporting my efforts.

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

Better Together Discounts may be automatically displayed in two places: on the product info page, and on a separate promotional page. We'll talk about the product info page first.

Customize the tpl_product_info_display.php file to advertise your discounts. Copy the file
includes/templates/template_default/templates/tpl_product_info_display.php

into the directory
includes/templates/<Your Template>/templates

Then modify tpl_product_info_display.php, and add this block of code:
<?php 
require($template->get_template_dir('/tpl_better_together_marketing.php',DIR_WS_TEMPLATE, 
   $current_page_base,'templates'). '/tpl_better_together_marketing.php');
?>
The placement of this code is a matter of personal preference; try placing it below the product description and adjust to your tastes.

The marketing text will appear like this on your product info page:

Buy this item, get a Microsoft Intellimouse Explorer at 50% off
Buy this item, get an item from Memory at 50% off


One or two div blocks of text will be produced depending on whether the item is the first or second parameter in an add_... call. For instance, if
   function setup() { 
      $this->add_prod_to_prod(8,12,"%", 100); 
      $this->add_prod_to_prod(12,17,"%", 100); 
   }
is used, then the product info page for products 8 will have one block of text with the div id betterTogetherDiscountPolicy which will say

"Buy this item, get name-of-product-12 free"

Product 12 will have a block of text with div id betterTogetherDiscountPolicy which will say

"Buy this item, get name-of-product-17 free"
"Buy name-of-product-8, get this item free"

Because this text has its own div id, styling it (changing font, color, etc.) is simply a matter of adding to your stylesheet

#betterTogetherDiscountPolicy {
   font-size: 200%;
   color: #ff0000;
}
This would give you

Buy this item, get a Microsoft Intellimouse Explorer at 50% off
Buy this item, get an item from Memory at 50% off

Probably a bit more obnoxious than you would truly want, but you get the idea.

Alternately, you could modify the marketing text template (tpl_better_together_marketing.php) and put the text into a fieldset:

 Better Together 
Buy this item, get a Microsoft Intellimouse Explorer at 50% off
Buy this item, get an item from Memory at 50% off


In version 2.1 and higher, the marketing text may also be displayed with images of the products. Use the following code in your tpl_product_info_display.php file:
<?php 
require($template->get_template_dir('/tpl_better_together_marketing_images.php',DIR_WS_TEMPLATE, 
   $current_page_base,'templates'). '/tpl_better_together_marketing_images.php');
?>


You will see the marketing text appear like this:

Product Info Page with Marketing Text and Images

Product Info Page with Marketing Text and Images

More Marketing Ideas

The other available marketing vehicle is the Better Together Discount promotional page. This page is completely optional; it is not included in the Better Together Contribution, but it is a free download. It creates a page that looks like this, displaying all discounts.

You may also optionally add an "Add both to Cart" button to the Promotional page; see the Better Together Promotional Page for details.

The Better Together Offers on Listing Pages extension displays the marketing text for your Better Together offers on listing pages such as All Products, Search Results and Manufacturer Pages.

Category Listing Page - Better Together Offers

Better Together Offers on Category Listing Page


Files

(new)  includes/languages/english/modules/order_total/ot_better_together.php
(new)  includes/modules/order_total/ot_better_together.php
(new)  includes/templates/custom/templates/tpl_better_together_marketing.php

Major Versions

  • 2.1 12/20/2009 Added images to marketing text
  • 2.0 09/01/2008 Added price sorting, add_cat_to_prod
  • 1.6 12/14/2007 Compatibility with 1.3.8.
  • 1.5a 09/18/2007 Fixed Google Checkout issue.
  • 1.5 09/08/2007 Fixed some messages; consolidated marketing text down to one div; only display marketing text if module turned on
  • 1.4a 07/31/2007 Simplified inclusion of marketing logic by adding it to this package. Some minor language improvements.
  • 1.3 12/30/2006 Adding marketing ability to print discounts in reverse order. (If buy A, get B free is offered, can now show this on B's page, not just A's page.) Allow products which are ordered in odd quantities to be used as twoforones *and* better together discounts if so specified. Previously, twoforone products were not additionally checked for better together discounts.
  • 1.2 12/03/2006 Adding explicit two for one support
  • 1.1 09/26/2006 Second Release (providing PHP 4 compatibility)
  • 1.0 09/15/2006 First Release

Bugs

  • Older versions of Better Together (prior to 1.6) require a patch to run under Zen Cart 1.3.8. Take this function and paste it right above the function calculate_deductions() in the file includes/modules/order_total/ot_better_together.php. The latest versions (1.6 and greater) include this patch, but if you haven't upgraded, you must manually apply the patch.

FAQ

Q: What's the difference between Buy Both Now and the Better Together Promotional Page with Add both to Cart?
A: They're two separate products. Buy Both Now works with the marketing text on the product info page; the Promotional Page with Add both to Cart works on the Promotional page.

Q: How do I install this software?
A: Installation instructions are here. If you've never installed a Zen Cart mod before, please read my Guide to Mod Installation on Zen Cart.

Q: How do I set up Better Together discounts?
A: Decide on the linkages you wish to use, and add them to the setup() function in includes/modules/order_total/ot_better_together.php. ("Linkages" are what "add_prod_to_prod," etc. are called.) Don't want to edit code? Get the Better Together Admin panel.

Q: Can I start and stop my Better Together discounts on certain dates in the future?
A: Please see Timing Discounts in Zen Cart for an explanation of how to do this.

Q: I'm using a category function - add_prod_to_cat() or add_cat_to_cat() or add_twoforone_cat() - and it's not working!
A: This is the most common question of all. Please see the Category Issues page for solutions.

Q: Why do you have to add PHP code to setup()? Why didn't you put this in the Admin panel?
A: When I created Better Together, I wanted it to be as flexible as possible, and I focused on functionality, not ease of use. Over time, the demand grew for an admin panel, and when the project got funded, I did it.

Creating the Better Together Admin panel was a significant amount of work and represents my main revenue stream for Better Together (the support for which consumes hours of my time every week); please show your support for my software by purchasing it.

Q: I would like my discounts to show up in the shopping cart. Why don't they?
A: The way the Order Total modules work is that they show up at checkout time. However, if you require the discounts to show up in the shopping cart, you may wish to show your support for Better Together by purchasing the Discount Preview module for $30.

Alternately, you may indicate that you have a Better Together discount policy by adding to TEXT_INFORMATION in includes/languages/english/shopping_cart.php, and inform the user that Better Together discounts will be calculated (and visible) at checkout time. Additionally, changing SUB_TITLE_SUB_TOTAL in the same file to something like 'Sub-Total BEFORE Discount' will emphasize the fact that a discount will be added at checkout time.

Q: How can I present my Better Together discounts on the product page?
A: Create your custom template if you haven't already done so. Then customize the file includes/templates/template_default/templates/tpl_product_info_display.php. Follow the directions in marketing in the installation instructions for details on the changes that are required.

Q: OK, I have the Better Together information on my product page, but my customers can't figure out that the discount isn't visible until checkout time
A: Add some explanatory text to the discount policy information you created above. This way it will show up every time there is Better Together information on a page. Alternately, you may purchase the Discount Preview module, or you may also add text to the shopping cart page to indicate that Better Together discounts will show up at checkout time as discussed above.

Q: OK, I have Better Together specials, but my customers aren't biting. How can I re-enforce the promotion?
A: My Checkout Candy module can be configured to show available Better Together discounts both on the Shopping Cart page and on the first page of checkout. Please consider showing your support for Better Together by purchasing this module.

Q: I don't want Discount Preview or Checkout Candy, but I'd still like to make a contribution to show my appreciation for Better Together - how do I do this?
A: Click here! All donations are greatly appreciated.

Q: What would my setup() look like if I wanted to give 2 for 1 on all items in category 1?
A: You have two options. This provides a two for one discount, allowing you to mix and match items from category 1:
  function setup() { 
      $this->add_cat_to_cat(1,1,"%", 100); 
  }


This provides a two for one discount on identical items in category 1:
  function setup() { 
      $this->add_twoforone_cat(1);
  }


Q: What would my setup() look like if I wanted to give 2 for 1 on all items 5, 8, 12, 17 and 31? What about buy one get one half off?
A: Here's what you would do for 2 for 1:
  function setup() { 
      $this->add_prod_to_prod(5,5,"%", 100); 
      $this->add_prod_to_prod(8,8,"%", 100); 
      $this->add_prod_to_prod(12,12,"%", 100); 
      $this->add_prod_to_prod(17,17,"%", 100); 
      $this->add_prod_to_prod(31,31,"%", 100); 
  }
Here's buy one get one half off:
  function setup() { 
      $this->add_prod_to_prod(5,5,"%", 50); 
      $this->add_prod_to_prod(8,8,"%", 50); 
      $this->add_prod_to_prod(12,12,"%", 50); 
      $this->add_prod_to_prod(17,17,"%", 50); 
      $this->add_prod_to_prod(31,31,"%", 50); 
  }


As in the previous question, mixing and matching is allowed with these discounts - but since these are specific products, what are the semantics of "mixing and matching?"

Well, for add_prod_to_prod() and add_twoforone_prod(), mixing and matching means "having different attributes." If you wish to give a buy one get one free for only precisely the same item for items 5 and 8, and not permit mixing and matching, you would use:
  function setup() { 
      $this->add_twoforone_prod(5);
      $this->add_twoforone_prod(8);
  }


For example, if you sell sweaters with the attribute "color," then buying a red sweater and a blue sweater would not produce a discount if add_twoforone_prod() were used, but it would if add_prod_to_prod() were used.

Q: What would my setup() look like if I wanted to do buy one of item 5, get one from category 2, 7 or 9 at $5 off?
A: Here's what you would do:
  function setup() { 
      $this->add_prod_to_cat(5,2,"$", 5); 
      $this->add_prod_to_cat(5,7,"$", 5); 
      $this->add_prod_to_cat(5,9,"$", 5); 
  }

Q: Can I do three for the price of two? Four for the price of three?
A: No. But You may also wish to look at Combination Discounts and Big Chooser can do this sort of discounting.

Q: What if I want to do offers on all my products?
A: The setup() function is in a php file, so you can write software to configure your discounts. For instance, if you have 600 products, and you want to do "buy one get one 50% off" on all of them, you can do:
function setup() {
   for ($i = 1; $i <= 600; $i++) {
      $this->add_prod_to_prod($i,$i,"%", 50);
   }
}
Obviously you could do this for add_twoforone_prod, etc. just as well.

Another approach would be to inspect the cart and call add_prod_to_prod (or whatever) on all items in the cart. The downside with this is that the marketing text then wouldn't work.

Extensions

The following Better Together extensions are available:
  • Make managing your discounts easier using the Better Together Admin panel.
  • The Better Together Offers on Listing Pages extension displays the marketing text for your Better Together offers on listing pages such as All Products, Search Results and Manufacturer Pages.
  • Buy Both Now allows you to provide a one-click interface to adding both linked items to the cart on the product info page.
  • Combination Discounts allows you to group more than two items together for discounting. It's Better Together for multi-item sets.
  • Big Spender allows you to provide "Better Together" style discounts based on the amount spent.
  • Big Chooser allows you to provide "Better Together" style discounts on more than two items with a variety of configuration mechanisms.
  • Show Better Together discounts on the shopping cart page using Discount Preview
  • Show Better Together cross selling text on the shopping cart page using Checkout Candy
  • Market your Better Together discounts using the Better Together Promotional Page.
I charge a fee for each of these extensions. Contact me for details.

Certificates of appreciation most welcome!
If the information you learned reading this site is helping your store make more money, please consider making a donation. Thank you!


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

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