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

Zen Cart Better Together Admin

Zen Cart Better Together Admin

Better Together Admin simplifies the process of adding discounts to Better Together.

Background: See the Zen Cart Matrix-o-discounts for a perspective on Better Together.

Relevance: Zen Cart™ 1.3.5-1.3.9, 1.5.x, along with Better Together.
This software will not work under PHP 8.
See interoperability for changes required for Edit Orders.

You must have JavaScript enabled in your browser.

This extension is part of the Better Together World.

Current Version: 3.4 (version history)

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

Cost: $30 (Upgrade for Zen Cart 1.3.x from prior version - $10) (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: $90.00 (Professional installation by That Software Guy)

Installation Difficulty: Moderate

Installation Instructions: click here for installation instructions

Common Installation Issues: click here for installation issues

Buy: Buy Better Together Admin!
Pre-purchase questions? No problem! Just Please contact me with your question.

FAQ: click here for FAQ

Video: You can see how to create a discount like "Buy product 14, get product 12 for 50% off" using Better Together Admin in this video:



Incompatibilities:
  1. This software is believed to be incompatible with Simple SEO URL by Numinix.
  2. This software will also not work with AJAX add-to-cart or checkout mods that do not reload the page when changing the cart contents or checking out. Please do not order this software if you are using these mods.
  3. This mod builds dropdowns of all categories with products and all products in a specific category once that category is selected.

    For this reason, if you have
    • over 400 categories containing products, or
    • categories with other 400 products in them,
    please do not buy this software; the dropdowns will not work. You can determine how many categories you have by doing this query in phpMyAdmin:
    SELECT COUNT( DISTINCT categories_id ) FROM products_to_categories;
    
    If you are using a prefix, you must include it in this statement (e.g. "FROM zen_products_to_categories" instead of "FROM products_to_categories" if your prefix is "zen_").

    Note that Discount Chooser does not have the limitation of 400 categories (or 400 products per category), so it is a better choice for larger stores.


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

Overview:

This page assumes a basic familiarity with Better Together.

Better Together is a very popular module, but many people have told me they dislike need to edit a file in order to add "linkages" (the term I used to describe associating one product with another for the purpose of discounting). So I created an admin panel which allows you to add linkages in a way which will be familiar to users of the Zen Cart admin system.


Better Together Admin Panel

Zen Cart Better Together Admin Panel

The page is broken into two areas: on the top, a list of existing discounts, and on the bottom, a form to allow you to add new linkages to create new discounts.

Discounts are listed in the order they were created. Discounts can currently be deactivated or deleted but not edited directly. To edit a discount, delete the existing one and create a new one.

When the screen comes up, all the fields are unset. The first step in creating a Better Together discount is to select the linkage type. The following linkage types are available:
  • Two for One - Products
  • Two for One - Category
  • A Product and a Product
  • A Product and a Category
  • A Category and a Category
  • A Category and a Product

Better Together Admin - Add a new linkage - initial screen

Zen Cart Better Together Admin - Add a new linkage



Once you select a linkage type, the appropriate fields are filled in for the first product or category and the second product or category. For instance, in this example, the Linkage Type "a product and a category" (add_prod_to_cat) is selected. The "Buy" dropdown is automatically populated with a complete list of categories, with a list of products for the selected category, and the "Get" dropdown is automatically populated with a complete list of categories. Choose the correct category, then the correct product within that category for the "Buy" item. Then choose the correct category for the "Get" item.

Better Together Admin - Add a new linkage - step 1

Zen Cart Better Together Admin - Add a new linkage

You then take the following steps:
  • Select the products or categories you want to link
  • Select the discount units (% or $ off, or Cross Sell), fill in the amount, set the start and end dates (if any)
and press "Submit."

Better Together Admin - Add a new linkage - step 2

Zen Cart Better Together Admin - Add a new linkage

The page refreshes, and you see your new linkage at the top of the list.

Better Together Admin - Add a new linkage - step 3

Zen Cart Better Together Admin - Add a new linkage


If you decide you don't want to offer one of your discounts, you have two options: you may permanently delete the discount with the "Delete" button, or you may temporarily suspend the discount with the "Set Inactive" button. When you set a discount inactive, the notation "INACTIVE" is painted next to the discount in red letters. This discount will not be applied at checkout, nor will it show up in the Better Together marketing text, on the Better Together Promotional Page, or in Checkout Candy on your shopping cart and shipping page.

The Set Inactive feature was added in Better Together 3.0; upgrades for Zen Cart 1.x are only $10.00 for prior purchasers.

The Date Start/End feature was added in Better Together 3.2; upgrades for Zen Cart 1.x are only $10.00 for prior purchasers.

Better Together Admin - set linkage inactive

Zen Cart Better Together Admin - set linkage inactive

When you inactivate a discount, the "Set Inactive" button changes to say "Set Active." To reactivate this discount, simply press the "Set Active" button.

Linkage Types

Better Together has four linkage types, plus two two-for-one types, as described in the Better Together help.
Zen Cart Better Together Admin Linkage Types

To review briefly, they are:
  • add_prod_to_prod()
  • add_prod_to_cat()
  • add_cat_to_cat()
  • add_cat_to_prod()
and
  • add_twoforone_prod()
  • add_twoforone_cat()

In this video, you can see how Better Together Admin handles the different linkage types by adjusting the screen to capture only the necessary data:


One to Many Behavior

In Better Together 2.5, a new feature called One to Many was added. This feature allows you to optionally re-use a condition item to multiple discounts.

However, there is one drawback. If you are using this feature (i.e. setting the One to Many value to 1 or 2), you should avoid discounts with overlapping products (e.g. prod_to_prod with the same item). It will cause double discounting if you do - for example using linkage type "a Product and a Product", and picking the same product (say product 27), and setting a 30% discount will actually wind up giving 60% off the second item 27. If you need both one to many discounts *and* BOGO style discounts, consider doing your BOGO discounts using Free Gift Chooser.

Installation Instructions:

Upgrading Instructions:

If you are upgrading from a prior version of Better Together Admin, follow these instructions rather than the installation instructions below:
  1. Unzip bt_admin.zip, and copy the contents of the unzipped admin and includes folders to the root directory of your shop. There is no need to reinstall xajax.
  2. In Admin > Tools > Install SQL Patches, run the following files:
    • old_sql/bt_admin_add_inactive.sql (if upgrading from Better Together Admin 2.0 or lower).
    • old_sql/bt_admin_add_date.sql (if upgrading from Better Together Admin 3.1 or lower).
    • old_sql/bt_admin_150.sql (if upgrading to Zen Cart 1.5.x or higher from 1.3.x).

Prior to Installation:

  1. Upgrade to the latest Better Together first. If you have not yet installed Better Together, do so. This includes doing Admin > Modules > Order Total > Better Together > Install. The download is available from the Zen Cart plugins - click here to download Better Together.
  2. Go into Admin > Tools > Store Manager, and click on "Reset ALL Products Master Categories ID".

Installation

  1. Back up everything! Try this in a test environment prior to installing it on a live shop, and please be sure to upgrade to the latest Better Together first.
  2. Two zip files are provided. Unzip both, and copy the contents of the two unzipped folders to the root directory of your shop. Note that the zip file bt_admin_xajax.zip is identical to the file cd_admin_xajax.zip from Combination Discounts Admin; there is no need to reinstall it if you have Combination Discounts Admin. Using PHP7? If you are running an older copy of this module, you need to upgrade. Get the new copy from my store.
  3. In your Zen Cart admin panel under Tools > Install SQL patches, run the following files:
    • bt_admin.sql (if upgrading from Better Together Admin 2.0 or lower).
  4. Edit the file includes/modules/order_total/ot_better_together.php Go to the bottom of file to the setup() function. If the inclusion of better_together_admin.php is commented out, uncomment it. (This is already done for you in newer versions of Better Together.)

    You should delete all manually entered discounts here so that all your discounts will be visible through the admin panel.
  5. Better Together Admin will now be available in the admin panel under Tools.


Installation Problems:

The most common installation problems for this module are as follows:
  1. Unfamiliarity with installing mods. Please review my Guide to Mod Installation on Zen Cart.
  2. A problem caused by the incompatibilities noted at the top of this help file
  3. Forgetting to modify includes/modules/order_total/ot_better_together.php as described above.
  4. Installing Buy Both Now, which changes includes/modules/order_total/ot_better_together.php and forgetting to reapply the modification noted above.
  5. A misunderstanding of "category." A category in Better Together is "the parent category of a product." See the Category Issues page for a discussion of the treatment of categories in my mods.
  6. Some hosts require scripts which are run from a URL - for example,
    http://your-store.com/your-admin/better_together_admin.php
    
    to have permissions 644. You may see a message like
    HTTP 500: Internal Server Error
    
    The server encountered an internal error or misconfiguration and was unable to complete your request.
    
    when running Better Together Admin if this is the case with your host. Simply set the permissions of admin/better_together_admin.php to 644 using your FTP client (or perhaps your cPanel File Manager).
  7. One European IE6 user reported that the linkage type dropdown was not responding. The fix was to match the XAJAX encoding type with what was actually being received from the server. At the top of the file admin/better_together_admin.php, under the version number, insert the line
    define ('XAJAX_DEFAULT_CHAR_ENCODING', 'iso-8859-1');
    
    (or whatever your encoding is).
    You can tell you have 8859-1 encoding if you look at your web pages and see a line like this close to the top:

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    


    If so, and your dropdowns are not responding, try this fix.
  8. Some people who use ISO 8859 encoding also have reported getting errors like this:
    PHP Warning:  htmlspecialchars() [<a href='function.htmlspecialchars'>function.htmlspecialchars</a>]: Invalid multibyte sequence in argument in 
    ... admin\includes\xajax\xajax_core\xajaxResponse.inc.php on line 1575
    

    If this is happening to you, edit the file admin/better_together_admin.php and delete the function addCreateOptions (around line 26-37). Insert this in its place:
      function addCreateOptions($sSelectId, $options) {
        $this->script("document.getElementById('".$sSelectId."').length=0");
        if (sizeof($options) > 0) {
           foreach ($options as $option) {
             $optval = $option['val']; 
             $text = htmlentities($optval); 
             $text = html_entity_decode( $text, ENT_NOQUOTES, "UTF-8" );
             $this->script("addOption('".$sSelectId."','".  $option['id']."','".$text."');");
           }
         }
      }
    

    If your products have the registered trademark symbol (®) in their names you need to make this change.
  9. If try to run the Admin Panel and get an error like
    1146 Table 'yourdb.zen_better_together_admin' doesn't exist
    in:
    [SELECT * FROM zen_better_together_admin ORDER BY id DESC ]
    If you were entering information, press the BACK button in your browser and re-check the information you had entered to be sure you left no blank fields.
    
    this means you ran the sql script in phpMyAdmin without adding the prefix manually. Delete the table "better_together_admin" and edit bt_admin.sql file and add your prefix (e.g. change better_together_admin to zen_better_together_admin if your prefix is "zen_".)
  10. You have installed Better Together, right? The admin panel doesn't include the basic module, which is a free download from the Zen Cart forum. This includes doing Admin > Modules > Order Total > Better Together > Install.
  11. I have seen installations where the AJAX queries fail (clicking linkage type does not populate the dropdowns for Buy and Get) because misplaced blank lines in PHP files. If you do a View Source in your browser and see something like this:

    Zen Cart Better Together Admin Installation Failure

    The blank line on line 1 means the DOM parsing of the page will fail. You must fix this before you will be able to use Better Together Admin.
  12. Running from a non-superuser account in 1.5.x? Please see this code change.
  13. Got a blank page? Review the guidelines for Debugging a blank page in Zen Cart
  14. Did you read the incompatibilities list? You may have too many categories, for example. If this describes you but you have already bought the software, please contact me; I may be able to write some custom logic (at additional cost) to help you make this mod work.

Issues with newer PHP Versions:

You must update to the latest version of this module if you are using PHP7. You can get the new copy from my store.

If you have the latest version and you are still 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.

Major Versions

  • 3.4 12/23/2018 - Update Zen Cart 1.5.6.
  • 3.3 11/05/2018 - Update for PHP7.
  • 3.2a 11/15/2014 - Fix to allow non-superusers to run if permitted.
  • 3.2 11/01/2013 - Adding start and end date support.
  • 3.1 05/02/2010 - Adding Cross Sell (requires Better Together 2.3 / Buy Both Now 2.3 or higher)
  • 3.0 01/01/2009 - Adding Set Inactive button
  • 2.0 08/31/2008 - Adding cat_to_prod
  • 1.0.3 07/19/2008 - Incompatibility with certain payment modules (PayPal IPN, etc.) fixed
  • 1.0.2 07/02/2008 - Language respected in creating lists.
  • 1.0.1 06/02/2008 - Sort prods/cats alphabetically, check JavaScript enabled.
  • 1.0 06/01/2008 - First release

Interoperability

  • If you are using Zen Cart 1.5.x and Edit Orders 4.x along with Better Together Admin, you must make the following change to includes/modules/order_total/ot_better_together.php:
    In function calculate_deductions(), below the global statement, add this code:
           if (IS_ADMIN_FLAG) { 
                require_once(DIR_FS_CATALOG . 'includes/./extra_configures/better_together_tables.php'); 
                require(DIR_FS_CATALOG . 'includes/modules/better_together_admin.php'); 
           }
    


FAQ

Q: Why do all my categories not show up?
A: The definition of a "category" in Better Together is "the parent category of a product." See the Category Issues page for a discussion of the treatment of categories in my mods.

Q: Why do I have to enable Javascript to run the Better Together Admin Panel?
A: Because it uses AJAX, a Javascript based technology. This creates a faster, more responsive user interface. If you do not enable Javascript in your browser, you will see a flashing red error message at the top of the page, and the Better Together Admin Panel will not operate.

Q: I would like to make it more obvious that a discount is inactive. How can I do this?
A: Edit the file admin/includes/bt_stylesheet.css and add
.inactive {
   color:#FF0000;
}
Now the entire line for an inactive discount will be red. Lines for active discounts use the ".active" class if you would prefer to do it the other way around.

I charge a fee of $30 for the Better Together Admin Panel. Buy Better Together Admin!
The fee covers software only; installation is extra if you require help.