The information in this thread might be outdated
If the solution did not help, please, check our Help Portal or contact Ecwid Team.
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 03-19-2014, 05:32 PM
Danny3928729834792h823's Avatar
Danny3928729834792h823 Danny3928729834792h823 is offline
Junior Member
 
Join Date: Mar 2014
Posts: 3
Default Simultaneously Link Categories and Products to an External Site

I'm trying to set up categories and products that link to external sites via the same store page, but the javascript snippets are cancelling each other. How can i set this up so both kinds of redirects work simultaneously?

Code:
<!-- START category 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 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 categoryURLs = {
  '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(categoryURLs[page.productId]) == 'string'
      && categoryURLs[page.productId].length > 0
    ) {
      window.location = categoryURLs[page.productId];
    }
  });
}
</script>
<!-- END product that links to an external site -->

Also your js base file on github appears to be down:
[You can use the following js file as a base for your own one:
https://raw.github.com/gist/1373124/44bea3e8c112a4fcb9ad288ac2693b80dab073ed/ecwid_category_redirects.js]
 
The information in this thread might be outdated
If the solution did not help, please, check our Help Portal or contact Ecwid Team.

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 08:04 PM.
Powered by vBulletin® Version 3.8.11. Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.