Skip to content

Instantly share code, notes, and snippets.

@makfruit
Created November 17, 2011 13:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makfruit/1373124 to your computer and use it in GitHub Desktop.
Save makfruit/1373124 to your computer and use it in GitHub Desktop.
A drop-in script for Ecwid to redirect a store visitor to external web pages after they open some categories.
<script>
// 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 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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment