Advertisement
belostotsky

Redirect 'Continue Shopping' button

Jun 30th, 2015
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script>
  2. if (typeof(Ecwid) == 'object') {
  3. Ecwid.OnAPILoaded.add(function() {
  4. // Redirect address. Change it to the URL of page where you want to redirect your customers.
  5. // You can use absolute or relative addresses, e.g. 'index.html', 'http://google.com'
  6. var continueShoppingRedirect = "http://google.com";
  7. // Continue shopping buttons CSS selectors
  8. // (you can remove the ones that you don't want to change behavior for)
  9. var buttons = [
  10. 'button.ecwid-productBrowser-cart-continueShoppingButton', // Cart page
  11. 'div.ecwid-productBrowser-cart-emptyCartPanel button.gwt-Button', // Empty cart page
  12. 'button.ecwid-ContinueShoppingButton-Invoice', // Order confirmation page
  13. 'div.ecwid-productBrowser-search-ContinueShoppingButtonContainer button.gwt-Button', // Search results page
  14. 'div.ecwid-Account-ContinueShoppingButtonContainer button.gwt-Button' // 'My account' pages
  15. ];
  16. // Pages (Ecwid.Page.type) where buttons should be customized
  17. var pages = [
  18. 'CART',
  19. 'SEARCH',
  20. 'ORDER_CONFIRMATION',        
  21. 'ACCOUNT_SETTINGS',
  22. 'ORDERS',
  23. 'ADDRESS_BOOK'
  24. ];
  25. Ecwid.OnPageLoaded.add(function(page) {        
  26. if (jQuery.inArray(page.type, pages) >= 0) {        
  27. var buttonObject = jQuery(buttons.join()).filter(":not('.clone'):visible");        
  28. if (buttonObject.length) {
  29. buttonObject.clone().addClass('clone').appendTo(buttonObject.parent()).click(function() {
  30. location.href = continueShoppingRedirect;
  31. });
  32. // Remove the original button
  33. buttonObject.remove();        
  34. }
  35. }
  36. if (page.type == 'CART') {
  37. jQuery('.ecwid-productBrowser-cart-clearBagButton').click(function() {
  38. var buttonObject = jQuery(buttons.join()).filter(":not('.clone'):visible");
  39. if (buttonObject.length) {
  40. buttonObject.clone().addClass('clone').appendTo(buttonObject.parent()).click(function() {
  41. location.href = continueShoppingRedirect;
  42. });
  43. // Remove the original button
  44. buttonObject.remove();
  45. }
  46. });
  47. }
  48. });
  49. });
  50. }
  51. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement