Turning off the Zen Cart Shopping Cart Sidebox on Specific Pages

I believe it is potentially confusing to show the shopping cart sidebox on pages which already display the shopping cart contents. Zen Cart has a built in feature to turn off the shopping cart sidebox on the shopping cart page (Go to Admin->Configuration->Layout Settings->Shopping Cart Box Status, and set this value to 2.). However, turning it off on additional pages is not difficult, and I recommend doing so. Here are the steps:

  1. If you do not have a includes/modules/sideboxes/YOUR_TEMPLATE/shopping_cart.php file, create one by copying the file includes/modules/sideboxes/shopping_cart.php.
  2. Above the line
       if ($show_shopping_cart_box == true) {

    add this block

         if ($show_shopping_cart_box == true) { 
            if (($current_page_base == "shopping_cart") || 
                ($current_page_base  == "account_history_info") ||
                ($current_page_base  == "checkout") ||
                ($current_page_base  == "checkout_payment") ||
                ($current_page_base  == "checkout_confirmation") 
               ) { 
                  $show_shopping_cart_box = false;

    I did not turn the sidebox off on the checkout shipping page, but you certainly may do so by adding that as a case.

Supporting Fractional Quantities for specific categories in Zen Cart

What if just some of the products in your Zen Cart can be added as fractional quantities?  This is the issue I faced.  I wanted my services to be able to be purchased fractionally, so someone could purchase (say) 2.5 hours of support.  Here are the required steps, with the categories to be supported for fractional products being 10 and 11, with units of 0.25 being the increments.  You should start by making a complete backup of your database.

  1. In PHPMyAdmin, run the commands
    UPDATE products SET products_quantity_order_units = 0.25 where master_categories_id in (10,11);
    UPDATE products SET products_qty_box_status = 1 where master_categories_id in (10,11);
  2. In Zen Admin, set Configuration->Stock->Product Quantity Decimals to 2.  This allows quantities to be set to 2 decimal places, which units of 0.25 requires.
  3. In Zen Admin, set Configuration->Product Listing->Display Product Add to Cart Button to 1.  This allows people to add to cart from the listing page, but without adjusting quantity.  You may skip this step if you wish to add the logic in the next  step to the file includes/modules/YOUR_TEMPLATE/product_listing.php.
  4. In includes/templates/YOUR_TEMPLATE/templates/tpl_product_info_display.php, right before the if statement that checks $products_qty_box_status, add this line of code:
    $products_qty_box_status = product_has_decimal_units($_GET[‘products_id’]);
  5. Create a function in includes/functions/extra_functions that implements product_has_decimal_units() by checking the product master category id for the specified product (and returns true if it’s 10 or 11).
  6. If your template uses the HTML5 input type=”number” option for quantity, you’ll need to add step=”0.25″ to the input element.

New PHP Versions and Better Together Admin / Combination Discounts Admin

If you are using Better Together Admin (Zen Cart or osCommerce) and getting a log message that looks like this:

Only variables should be assigned by reference in YOUR_ADMIN/includes/xajax/xajax_core/xajaxPluginManager.inc.php on line 268

or this:

PHP Strict Standards:  Non-static method xajaxPluginManager::getInstance() should not be called statically, assuming $this from incompatible context in YOUR_ADMIN/includes/xajax/xajax_core/xajax.inc.php on line 269

Then please refer to the instructions for fixing this issue on the Better Together Admin help page.

The same instructions apply for Combination Discounts Admin.

Keeping your Zen Cart Downloads folder safe

The default folder for Zen Cart downloads is <your_store_root>/download.  The problem with this is that if you have non-free downloads, and some bad guy guesses the names of your zip files, they can just download them for free.

The fix is easy; simply relocate your downloads folder outside of your public_html directory.  So if your DIR_FS_CATALOG entry in includes/configure.php is ‘/home/scott/public_html/shop’, just do this:

  1. Move your /public_html/shop/download folder to /download (i.e. above public_html)
  2. Set DIR_FS_DOWNLOAD to ‘/home/scott’ in includes/configure.php and YOUR_ADMIN/includes/configure.php

Some more details on this are discussed in this Zen Cart tutorial.

Building a static site on Github with Hugo

The cool kids are using Hugo to build static websites, so I wanted to give it a try myself.   It was easy enough to use locally, but the instructions on the website for Hugo hosting on Github pages were too complicated for me.  So I used what I think is a simpler workflow, and documented it in my site’s README.md.  Here you go:

  1. Install Hugo.
  2. Use
    hugo new site my-site-name

    to create the site. Change directory to my-site-name.

  3. Grab a template you like from HugoThemes. Create the directory themes and install it there.
  4. Run
    hugo server -w

    to start looking at your site locally. Add content until you’re happy.

  5. Fiddle with config.toml until you’re happy. Remember you have to restart “hugo server” each time you change configuration; the LiveReload doesn’t handle this.
  6. Create a .gitignore and add “public” to it.
  7. Add your site to a new git repository. For reference, mine is https://github.com/scottcwilson/hugosite.
  8. Run

    to generate the final copy of your site. (I assume you have added your template to the config.toml file; if not, you will need to use “hugo -t your-template”.) Change directory to “public”.

  9. Add this directory to a new repository, with the name your-github-name.github.io. Again, for reference, mine ishttps://github.com/scottcwilson/scottcwilson.github.io.
  10. You’re done! Your site will be live shortly at http://your-github-name.github.io.