Created
November 17, 2011 13:27
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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