View Single Post
  #2  
Old 03-21-2014, 05:13 AM
Maya's Avatar
Maya Maya is offline
Ecwid Team
 
Join Date: Feb 2010
Location: Ecwid headquarter
Posts: 5,876
Default

Hello,

Please, try following code to redirect customer to the custom page, when Ecwid category or product were clicked:

Code:
<script>
// categoryURLs array as category Id => redirection URL
// Please use this array to define your own redirection rules
var categoryURLs = {
  '1234567' : '/index.html', // Sample 01 Category Page redirects to Homepage
  '2345678' : '/index.html' // Sample 02 Category Page redirects to Homepage
};
 
// Add handler for Ecwid's OnPageLoad event
if (
  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];
    }
  });
}
</script>
<!-- END category that links to an external site -->

<!-- START product that links to an external site -->
<script>
// categoryURLs array as category Id => redirection URL
// Please use this array to define your own redirection rules
var productURLs = {
  '123456789' : '../sample-product-page.html'
};
 
// Add handler for Ecwid's OnPageLoad event
if (
  typeof(Ecwid) == 'object'
  && typeof(Ecwid.OnPageLoad) == 'object'
) {
  Ecwid.OnPageLoad.add(function(page) {
    // Redirect user if needed
    if (
      typeof(page) == 'object'
      && 'PRODUCT' == page.type
      && typeof(productURLs[page.productId]) == 'string'
      && productURLs[page.productId].length > 0
    ) {
      window.location = productURLs[page.productId];
    }
  });
}
</script>
<!-- END product that links to an external site -->
Use categoryURLs array as a list of categories IDs and productURLs as a list of product IDs.

Good luck!
__________________
Maya N., Ecwid Team

------------------
Welcome to our new Help Center!

Last edited by Maya; 03-25-2014 at 12:25 PM.