That Software Guy, Inc.'s Logo

Software Consulting Services
Need Help? Call That Software Guy!

better together

Better Together

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

Background: See the Zen Cart Matrix-o-discounts

Relevance: Zen Cart™ 1.3.5 and forward

Cost: Free, but donation appreciated

Location: Zen Cart Downloads page, under Marketing Tools

Download: Better Together On Zen Cart Downloads Page

Promotional Page Download: free from my website

Current Version: 1.6

Changes in 1.3.8: Better Together requires 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.

Support Thread: Better Together Support Thread

FAQ: click here

Installation: 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:
         $this->add_prod_to_prod(14, 12, "%", 50);


Add-Ons:
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.

Here is a sample of the Better Together Discount promotional page, which is described in this tip.

Bugs: click here

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

Discounts may be specified as percentages of the latter item's price or as absolute values in the currency you 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).

Payment Page displaying Better Together Discount

Payment page showing Better Together discount

Detailed Description:

Linkages are specified in the setup() method at the bottom of the class. Several examples are provided.
Three 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 three calls for the three types of discounting are
  • add_prod_to_prod()
  • add_prod_to_cat()
  • add_cat_to_cat()
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. In the setup() function, add the line
   $this->add_prod_to_prod(2,5,"%", 50); 

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

How about buy one product 2, get one free?
   $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
   $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
   $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
   $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:
   $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
   $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
         $this->add_twoforone_prod(5);
And to create two for one discount for all products in category 3, code
         $this->add_twoforone_cat(3);


Note the difference between
         $this->add_twoforone_cat(3);
and
         $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.

Note that the "category" in add_cat_to_cat() and add_prod_to_cat() is the parent category. If subcategories are being used, the parent category will not be the same as the top level category.

Men's Clothing 
     |
     ---->  Shirts
            |
            -------> 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 top level categories, you may wish to consider purchasing the Multilevel Category extension for Better Together.

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) by following the links at the top of this page.


Marketing

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
      $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


NB: Prior to Better Together 1.5, the marketing text was broken into two divs (discountPolicy and discountPolicyReverse); in 1.5, it was consolidated into a single div called betterTogetherDiscountPolicy.

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 from my website. It creates a page that looks like this, displaying all discounts.

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

Bugs

  • Better Together versions 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 include this patch, but if you haven't upgraded, you must manually apply the patch.

FAQ

Q: How do I install this software?
A: 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.)

Q: Can I start and stop my Better Together discounts on certain dates?
A: Please see the Timing Discounts 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: Although it's a bit tedious to have to manually code the associations, it maximizes the module's flexibility and allows me to easily add things like the two-for-one special (new in 1.2). If you need help with the setup logic, I will be happy to do it for you for a small fee.

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 Quantity Discounts can do this sort of discounting. You may also wish to look at Combination Discounts.

Extensions

The following Better Together extensions are available:
  • Buy Both Now allows you to provide a one-click interface to adding both linked items to the cart.
  • Combination Discounts allows you to group more items together in more ways that Better Together.
  • Big Spender allows you to provide "Better Together" style discounts based on the amount spent.
  • Don't restrict discounting to a single pair of items; when the first item is purchased, discount all of the second items purchased
  • Don't apply Better Together discounts for products which are on special
  • Make Better Together to use top level categories, not parent categories
  • 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
I charge a fee for each of these extensions. Contact me for details.

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 | ©2003-2008 That Software Guy, Inc.