If you want some category in UXi® Commerce to link to an external site or to a separate page of your site, you just need to add a special JavaScript code after the UXi® Commerce integration code on the page where your store is installed. This code uses the UXi® Commerce Javascript API for handling the UXi® Commerce 'OnPageLoad' event and redirecting your visitors to an external page if they try to open some particular category in UXi® Commerce. 

Please see this code below.


// categoryURLs array as category Id => redirection URL

// Please use this array to define your own redirection rules

var categoryURLs = { '1765387' : 'http://www.google.com', '1797366' : 'http://www.ecwid.com'}; // Add handler for Ecwid's OnPageLoad eventif ( typeof(Ecwid) == 'object' && typeof(Ecwid.OnPageLoad) == 'object') {

Ecwid.OnPageLoad.add(function(page) { // Redirect user if needed if ( typeof(page) == 'object' && 'CATEGORY' == page.type && typeof(categoryURLs[page.categoryId]) == 'string' && categoryURLs[page.categoryId].length > 0 ) {

window.location = categoryURLs[page.categoryId];

} });



view rawecwid_category_redirects.js hosted with ❤ by GitHub


This code works for any UXi® Commerce store, however the very first part of it should be modified to fit your exact needs. The part which requires modifying is this one:

// categoryURLs array as category Id => redirection URL                                                                                                 
var categoryURLs = {                                                                                                                                    '1765387' : 'http://www.google.com',                                                                                                                  '1797366' : 'http://www.ecwid.com'                                                                                                                   };   In order to set redirection rules for your store you should edit the 'categoryURLs' variable. In the example above:- 1765387 and 1797366 are the IDs of categories which should link to external pages;- 'http://www.google.com' and 'http://www.ecwid.com' are those pages.Notes:1. To get the ID of the category you want to set as a link in your store please refer to this document: http://kb.ecwid.com/w/page/23947812/How%20to%20get%20ID%20of%20your%20product%20or%20category

2. When you edit the list of category URLs please make sure that each URL is properly enclosed in quotation marks and each line ends with comma except the last line.


You can use the code above on all of your storefronts because category IDs remain the same for all of them. Moreover, since it is not changed from one storefront to another, the best way to use it is to place it in a javascript file (with a .js extension) and call this file on multiple pages instead  of pasting the code into pages one by one.


You can use the following js file as a base for your own one:



To make it work please do the following:

  1. Download this javascript file.
  2. Modify redirection rules as I described earlier in this post.
  3. Place it  somewhere in the web with public access.
  4. Specify the location of the external JavaScript file on the page you want it to be executed on by appending a link to it to your UXi® Commerce integration code. Such a link should look like this:
<script type="text/javascript" language="javascript" src="www.example.com/myfile.js"></script> 

where "www.example.com/myfile.js" should be replaced with the location of the file. 


The described method (with inclusion of a js file) is also recommended for Wordpress users. The Wordpress editor that is used to edit the source code of UXi® Commerce shop page parses JavaScript codes incorrectly. So it is safer to use the script in the external file as described above, even if you use the WP 'UXi® Commerce-shopping-cart' plugin for your store integration. You need to find a page where your UXi® Commerce store is installed (it can be found under the 'Pages' tab in your WP admin panel, usually it is called Store), edit it, switch to HTML editor and insert a link to your external JavaScript file into its source after all the UXi® Commerce integration codes. 


There is also a more simple way to make the links in the category listings by adding those links into the category description (see UXi® Commerce control panel → Catalog → Categories, select the category you need and edit the description in the Category description area at the bottom). But this way your custom links will appear above all the other category contents and not among the other subcategories.


For product details

You also can use this solution, if you need to redirect customer to another page upon visiting the products details page of a particular product. You just need to change the code above a bit. Change “CATEGORY” to “PRODUCT” in this line


&& 'CATEGORY' == page.type


so that it reads as

&& 'PRODUCT' == page.type

change “page.categoryId” variable to “page.productId” in the code, and of course use the product IDs instead of category IDs accordingly.