Zen Cart Multi-Language

Zen Cart really is quite robust ecommerce software. Setting up your Zen Cart to offer multiple languages is pretty common, if you are just getting started go here. This post is designed to help multiple language Zen Carts correctly direct the search engines to the correct language specific page when appropriate.

Zen Cart 1.3.9 and newer has the awesome rel=”canonical” links in the <head>, so we can use this function to better offer up our multilingual pages!

Your language links are conveniently appended with their language ID. URLs such as (/index.php?main_page=index&language=es) contain the language parameter to correctly produce the desired language for your site’s visitors.

That’s the easy part … your shoppers can easily use the language switcher to change languages and shop….. But what about Google?

Using the rel=”alternate” hreflang=”x” tag will help Google serve the correct language or regional URL when appropriate. Google says:

Some example scenarios where rel="alternate" hreflang="x" is recommended:

  • You translate only the template of your page, such as the navigation and footer, and keep the main content in a single language. This is common on pages that feature user-generated content, like a forum post.
  • Your pages have broadly similar content within a single language, but the content has small regional variations. For example, you might have English-language content targeted at readers in the US, GB, and Ireland.
  • Your site content is fully translated. For example, you have both German and English versions of each page.

The cool part is that now with the robust canonical URLs built in to Zen Cart we can easily accomplish this.

In includes/templates/your_template/common/html_header.php


<base href=”<?php echo (($request_type == ‘SSL’) ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG ); ?>” />
<?php if (isset($canonicalLink) && $canonicalLink != ”) { ?>
<link rel=”canonical” href=”<?php echo $canonicalLink; ?>” />

Then Add the Following for Edited for Your Language Options:

<link rel=”alternate” hreflang=”es” href=”<?php echo $canonicalLink; ?>&amp;language=es” />

Before the <?php } ?>

So the whole statement with 1 language added would look like this:

<base href=”<?php echo (($request_type == ‘SSL’) ? HTTPS_SERVER . DIR_WS_HTTPS_CATALOG : HTTP_SERVER . DIR_WS_CATALOG ); ?>” />
<?php if (isset($canonicalLink) && $canonicalLink != ”) { ?>
<link rel=̶