How to install Simple Google Analytics in Zen Cart

I managed to get Simple Google Analytics Version: 1.2.5 to work for me on Zen version 1.5 and added to the admin menu. I thought I’d share.

The new GA version does not seem to have a language file to define one of the settings for the admin menu to appear. I created this file: admin/includes/languages/english/extra_definitions/googleanalytics.php and placed the following code in this file:

<?php
define('UN_BOX_GOOGLE_ANALYTICS', 'Simple Google Analytics');

Here are the settings I used in the admin registration page.

Page Key: Simple Google Analytics
Page Name: UN_BOX_GOOGLE_ANALYTICS
Page Filename: FILENAME_CONFIGURATION
Page Parameters: gID=36 (make sure you look up this in your database because the number will be different. see below on how to do this.)
Menu: configuration
Display on Menu? Y
Sort Order: whatever you want

To find the gID number run this select statement in phpMyAdmin:

SELECT * FROM `configuration` WHERE configuration_key like ‘%google%’

Then look for the configuration_group_id. This is the number to use after gID=

I hope this helps someone!

Read More

Comparison Shopping Site Automation for Zen Cart

Do you need to integrate your Zen Cart with shopping sites like Shopping.com, Bizrate, Nextag, Pricegrabber, etc? This may be a good solution for you.

This solution does not integrate with the Zen Cart administration area. This is a stand alone mini application of sorts that connects to your Zen database and would need to be placed in a password protected directory on your server.

The interface lists all the products in your Zen database with checkboxes next to each. The list is sorted by price so you can click all products above/below a price threshold if you like.

Included are a few PHP files that would need cron jobs to run weekly, or whenever you schedule them to run. Most shopping sites like to be updated weekly. So, this would save you lots of time and eliminate the need to maintain multiple spreadsheets and upload them each week. The system would do all this for you automatically.

Server requirements: PHP 5, ability to run cron jobs

Installing and configuring should be done by an experienced web developer. This is a no frills, bare bones mini application that runs efficiently. So, there are no pretty graphics on the interface. Just good old fashioned functionality.

Of course, I’m available to install this on your server. Contact me for details including pricing.

Read More

Mod for Zen Cart – Dynamic Dropdown Menu System

I created a pretty cool little mini mod (of sorts) and I thought I’d share it here in case anyone is interested in using it. I have not prepared it for distribution because I’m not even sure if anyone is interested yet. But, I’ll put a zip file together for anyone that is. Here’s the scenario.

Let’s say you have created categories and manufacturers for each product but you always feel like you need to create new ones because your think your customers may use varied terms to describe the same product/category/manufacturer. Having too many categories may also alienate some visitors because they are overwhelmed by the large list you have running down the left sidebox. Or, it takes too many clicks to get where you want them to go.

Because it can take you forever to make these updates manually, if you continually change these names, in time you may get yourself into a chaotic mess. Not to mention the fact that you are constantly changing URLs which may not play well with Google and SEO.

I’ve found that if you put your Manufacturers sidebox (with dropdown menu enabled) in one of the upper corners of your site, many viewers like to use it. If you have intuitive names, then you’ll get lots of clicks. But, if your popular product is made by an unknown manufacturer, viewers will not recognize it in the list.

Incidentally, if you’re exporting your products from Zen to use for shopping comparison sites (Shopzilla, Nextag, Shopping.com, etc), they will have much better luck listing your products correctly if you supply them with the correct manufacturer name. If you have changed the manufacturer names to something different than they actually are, (to make it more intuitive for the viewer), and use this in your datafeeds, they may either be rejected or may not list properly on their site. (This is what got me started on this project.) I also wrote some scripts to automate some shopping site datafeeds if you’re interested.
dropdown-menu-screen-shot

So, I built a little tool that allows you to display a separate drop down menu that functions like the Zen Manufacturers menu (with much less Javascript). But, it pulls info from a custom table. It’s a simple 1 table set up that allows you to enter a link name and a destination URL. This way, you can link to any page using any text you want, anytime you want. It’s using Javascript so I don’t think it will affect SEO. It’s simply a tool where you can stray from the norm and easily enter your own link names and see if that improves conversions. If you find something that works, you might then think about updating a category name or two, and doing the proper 301 redirects for SEO (unless you’re using a good SEO mod that automatically does this).

This is not a “mod” per se. I wrote a few admin screens (separate from Zen) that you would place into a password protected directory. It’s a bare bones script so it needs to be somewhere secure. I’m not the greatest PHP coder! But, it does work great.

The table has only a few fields but you could add more for things like tracking or something. You’d have to update the scripts accordingly.

I wrote a simple SQL query and Javascript to display the dropdown menu. I plopped mine into the sideboxes/tpl_manufacturers_select.php page so it would have 2 dropdown menus, one below the other. Of course, you would have to style it to suit your site template.

If you’re interested, let me know. Trying to give back!

Read More

Automate Google SitemapXML mod in Zen Cart

Does your client make a lot of updates to their website? Like add/edit/update products a lot? Or, add EZ pages a lot? There is a Zen Cart plug in (SitemapXML (formerly “Google Sitemap”)) that generates a properly formatted XML site map for Google. You can get it here:
http://www.zen-cart.com/index.php?main_page=product_contrib_info&products_id=544

Download and install it according to their instructions.

The site map needs to be manually updated from within the admin panel. This means your client or developer will need to remember to do this. Not good. So, let’s automate it. Below are instructions on how to do this. You’ll need to be able to write and schedule a cron job on your web host account.

Step 1: Install the SitemapXML mod.

Step 2: Call the page that generates the XML file with a cron job using cURL. Schedule it to run according to how many updates your client is making. The schedule is set by using your cPanel or similar application supplied by your web host.

It’s now automated.

CRON JOB 1:

curl http://www.YOUR-WEBSITE.com/index.php?main_page=sitemapxml

Now, if you want to ping Google, Yahoo!, Ask.com, and Microsoft after each new XML file generated, you would run the following cron job. But, it’s not really necessary to ping them, especially Google, because they will naturally crawl your site every few days anyway.

CRON JOB 2:

curl http://www.YOUR-WEBSITE.com/index.php?main_page=sitemapxml&genxml=no&ping=yes

That’s all there is to it!

 

Read More

How to avoid database lock up in Zen Cart

I was having issues with the database locking up on the server. Each time Zen Cart makes a query of the database, it is locked and then unlocked when the query finishes. I have a lot of processes outside of Zen Cart also running on the server. Periodically, the server would lock up and I would need to manually restart SQL. This was becoming a pain. So, I investigated the queries Zen Cart was making and found one that is called every time a page is viewed. It’s the Zen Cart hit counter.

This is used to display the number of hits in the Zen Cart admin area. If you’re using Google Analytics like most of us, there is really no need for the Zen Cart counter. So, I commented out the line and it seemed clear up the problem. The database has not locked up since.

I can’t guarantee this will cure the problem however. There are so many queries going on in Zen Cart it’s difficult to find the culprit.

**UPDATE** My database did lock up again after a month or so since I made this update. While it did certainly seem to help, there may be some other issues at hand. By the way, the site is hosted on Rackspace (tier 1 provider), and not in a cloud, so this has nothing to do with being on a shared server. They supplied me with a report on the SQL queries that had locked up some of the tables. Most of the queries looked like they came from the Zen admin area by looking up customers and orders. There are over 35k records in the customers table. This doesn’t seem to be excessively large. The version of Zen Cart I’m using is a little outdated, v1.3.9e and I’m not sure if v1.3.9g would make a difference.

Simply comment out the line below with a double slash (as shown) in your /includes/application_top.php file.

// require(DIR_WS_INCLUDES . 'counter.php');

 

Read More

How to remove sideboxes from product pages in Zen Cart

It took me a while to figure this one out. The Zen forum contains a more elaborate solution that includes removing a sidebar from the category pages as well as the product description pages. I just wanted to remove the sidebar from the product description pages. So far, this seems to work fine for me. I thought I’d share it with you.

Simply copy and paste the code below as the first line of your PHP code on the /includes/templates/YOUR-TEMPLATE/templates/tpl_product_info_display.php page.

<?php
// to disable right sidebar
 $flag_disable_right = true;
 
// to disable left sidebar
 $flag_disable_left = true;
?>
Read More

How to add a MySQL query to a Zen Cart page

It took me a while to figure out how to write my own MySQL query with the correct PHP syntax that Zen Cart likes. I thought I’d share it with you.

For example. Lets say you want to find out how many reviews were made for a particular product and display the number on the product description page. You would use the following and place it on your /includes/templates/YOUR-TEMPLATE/templates/tpl_product_info_display.php page. Of course, modify the style to match your page.

<?php
$this_sku_sql_for_reviews = "SELECT COUNT(products_id) as products_id, status FROM reviews where products_id = '" . $_GET['products_id'] . "'";
$this_sku_reviews = $db->Execute($this_sku_sql_for_reviews);        
    if($this_sku_reviews->fields['status'] == 1) {
        echo "<p align=\"center\" style=\"font-size:10px;margin-bottom:5px;\">". $this_sku_reviews->fields['products_id']." reviews</p>";
    }
?>
Read More

How to place social media links in Zen Cart

There’s been a lot of discussion about whether the default Facebook like button code is good or not for SEO. Not to mention all the errors on the Facebook side (Like button), that makes it too time consuming to deal with.

To try and play it safe, I decided to add my own PHP code that should not have the same issues. But, it’s not going to show the number of likes (or Tweets). It simply adds the current page link to each social media site button. It’s using the correct Facebook URL (currently), and will open the correct page on Facebook along with a link to your page. It also allows the user to place a comment and then share.

I added the same type of functionality to the Twitter and Google +1 buttons, too. Right click and save the icons below to your server. Make sure you change the path in the image tag to wherever you upload the icon on your web server.

I recommend placing this code in your /includes/templates/YOUR-TEMPLATE/templates/tpl_product_info_display.php page so the social links appear on your product description pages. You’ll have to find the right spot to place them because every template is different. Try placing it after the <!–eof Product description –> tag and see how that works for you.

Actually, this also works on most any PHP page. It works on demo area below!

DEMO

Spread the Word
Share on Facebook Tweet This Page

Below is the code.

<?php
$urlforshare = (!empty($_SERVER['HTTPS'])) ? "https://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] : "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'];
//echo $urlforshare;
$urlforshare2 = str_replace('/', '%2F', $urlforshare);
?>
<div style="border: 1px solid #cbcbcb;background-color:#ececec; width:175px; margin-top:17px;">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
    <tr>
	    <td style="text-align:center !important; padding-top:5px;padding-bottom:5px;" align="center">
<a href="http://www.facebook.com/sharer/sharer.php?u=<?php echo $urlforshare2;?>" target="_blank" title="Share on Facebook" rel="nofollow"><img src="facebook.gif" alt="Share on Facebook" width="16" height="16" border="0"></a>
        </td>
        <td style="text-align:center !important; padding-top:5px;padding-bottom:5px;" align="center">
<a href="http://twitter.com/intent/tweet?text=<?php echo $products_name; ?>&url=<?php echo $urlforshare2;?>" target="_blank"  title="Tweet This Page" rel="nofollow"><img src="tweet.gif" alt="Tweet This Page" width="50" height="16" border="0"></a>
        </td>
        <td style="text-align:center !important; padding-top:5px;padding-bottom:5px;" align="center">
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script><g:plusone size="small" count="false"></g:plusone>
        </td>
        <td style="text-align:center !important; padding-top:5px;padding-bottom:5px;" align="center">
<p style="font-size:11px;font-weight:bold;color:#2c5987;">SHARE</p>
        </td>
    </tr>
</table>
</div>
Read More