Archive for the ‘Advanced Zen Cart Tips’ Category

Activating an Inactive Coupon in Zen Cart

Thursday, March 5th, 2009

Recently a client needed to re-activate a coupon in Zen Cart. She wanted to re-use the exact same coupon but had inactivated the original.

After exploring the Zen admin, I could find no way to re-activate a inactive coupon so used the SQL query below.

Copy and the code below and paste it in Tools -> Install SQL Patches. Make sure you change the coupon_id to the number that you would like to re-activate. To get the id number, click on the name in Gift Certificate/Coupons -> Coupon Admin, the id is in the right column, in square brackets before the coupon name. And, as always, BACK UP YOUR DATABASE before making any changes to your Zen Cart installation.

UPDATE `coupons` SET `coupon_active` = 'Y' WHERE `coupons`.`coupon_id` =22 LIMIT 1 ;

Using Zen Cart’s cPath System for Style Changes

Tuesday, August 26th, 2008

You probably already know that you can style certain category links differently based on the cPath. If not take a look at the notes in the file includes/templates/template_default/sideboxes/tpl_categories.php.

Using that same method, you can style the header, footer, and other parts of your site depending on the current cPath.

For example, let’s say you have a category on your web site that lists children’s decor. You want this area to have a more playful feel with a polka dot background for the header area. The category path is 5.

1. Open includes/templates/template_default/common/tpl_header.php

2. Right before the <div id=”headerWrapper”> type:

<?php
if ((int)$cPath == 5) {

<div id =”headerWrapperChildrens”>

the rest of the code here

</div>

} else {

<div id=”headerWrapper”>

the rest of the code here

</div>

}

3. Save the file and upload it to includes/templates/YOUR_CUSTOM_TEMPLATE/common/

4. Open your stylesheet.css file and define the style for #headerWrapperChildrens

Of course, this approach can be taken with many sections of your web site, the possibilities are up to you!

Using PHP str_ireplace() Function to Help with Zen Cart SEO

Friday, August 15th, 2008

This Zen Cart SEO tip is very esoteric, I’ve only used it once but with great results.By using php’s str_ireplace() function, you are able to name your categories with SEO in mind.

Background: Let’s say you sell everything red; red dresses, red hats, red shoes and so on. Your store is even named The Red Store. When setting up your categories you create Red Hats, Red Dresses, etc. You have the SEO mod installed and your url reads “red-dresses-c-1.html” , so far so good. But now you go to the front of your site and you just don’t like the way the category names look…. do customers really need to see “Red” before every category name?
Use: In my application, the web site is using category tabs across the top of the header and changes will relate to that set up but with a bit of thought you can use this tip no matter which category option you are using.

Download includes/modules/categories_tabs.php at the bottom of the file look for:

// create link to top level category

$links_list[] = ‘<a class=”‘ . $new_style . ‘” href=”‘ . zen_href_link(FILENAME_DEFAULT, ‘cPath=’ . (int)$categories_tab->fields['categories_id']) . ‘”>’ . $categories_tab_current . ‘</a> ‘;

$categories_tab->MoveNext();

And replace with:

// create link to top level category

$links_list[] = ‘<a class=”‘ . $new_style . ‘” href=”‘ . zen_href_link(FILENAME_DEFAULT, ‘cPath=’ . (int)$categories_tab->fields['categories_id']) . ‘”>’ . str_ireplace(”RED”,”",”$categories_tab_current”) . ‘</a> ‘;

$categories_tab->MoveNext();


Upload your edited file to includes/modules/yourCustomTemplate/

Go to your web site to see your changes. The category names are now just dresses, hats, shoes etc but the url, breadcrumb and headline tags have the complete category name. I would love to hear about how you’ve used this tip!

Two Types of Cross Sell in Zen Cart

Tuesday, July 15th, 2008

One of the things I love about Zen Cart is that it is so intuitive. Once you begin to learn the program and structure, almost anything is possible.

Recently, I had a situation where a client wanted to have regular products with the Cross Sell mod. In addition, she wanted to have a “Press” area where she could easily add press coverage to the web site. She wanted to be able to add recent press herself and then provide photos and links to the items featured in the press piece.

I knew I could do this with Zen Cart but there were a few difficulties:

  1. What would be the easiest way to add the press pieces?
  2. How to use the Cross Sell in two different ways? (on product pages, the Cross Sell would say “You May Also Like” and on the press pages, the Cross Sell needed to say “Buy the Pieces”)

After some thought, I came up with the following plan:

  1. Add a Press category to the product catalog. Limit the Product Type for the Press category to a General Document. (No need to actually purchase the Press item)
  2. Copy the Cross Sell mod (available in the Zen Cart downloads section) and change the file and database table names. This way I was able to have two different types of Cross Sell.

If you are interested in using my Second Cross Sell mod, please send me an email at info(at)zencarttips(dot)com with a link to some zen cart work you have done. I won’t be able to offer support for the mod, so please only email me if you have experience installing zen cart mods and know how to edit zen cart files.

I heart zen cart:)

How to Remove the “Specials” Link on the Site Map if There are no Specials

Monday, June 30th, 2008

You may have noticed that the default Zen Cart Site Map file contains a link to the “Specials” page whether or not your store has any current specials. To make this link appear only if you have current Specials, first we create a SQL query, then we reference the query to see if there are specaials, if so create the link.

First the usual drill…. Always make back ups of your files and always upload any changed files to your custom template directory.

Download tpl_site_map_default.php from includes/templates/template_default/templates directory.

Find:

<li><?php echo ‘<a href=”‘ . zen_href_link(FILENAME_SPECIALS) . ‘”>’ . PAGE_SPECIALS . ‘</a>’; ?></li>

Replace with:

<?php

$specials_index_query = “select distinct p.products_id, p.products_image, pd.products_name, p.master_categories_id

from (” . TABLE_PRODUCTS . ” p

left join ” . TABLE_SPECIALS . ” s on p.products_id = s.products_id

left join ” . TABLE_PRODUCTS_DESCRIPTION . ” pd on p.products_id = pd.products_id )

where p.products_id = s.products_id

and p.products_id = pd.products_id

and p.products_status = ‘1′ and s.status = ‘1′

and pd.language_id = ‘” . (int)$_SESSION['languages_id'] . “‘

and p.products_id in (” . $list_of_products . “)”;

if ($specials_index_query > 0) { ?>

<li><?php echo ‘<a href=”‘ . zen_href_link(FILENAME_SPECIALS) . ‘”>’ . PAGE_SPECIALS . ‘</a>’; ?></li>

<?php } ?>

Upload the modified file to: includes/templates/YOUR_TEMPLATE/templates directory.

Now check your site map, if you have no specials there will be no Special link.