Advertisement
belostotsky

Change Continue Button URL for Wix

Jan 26th, 2015
261
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 PAGE_ID = "c1x9v";
  7.  
  8.     // Delay (ms), which is necessary for the empty cart page to appear after onCartChange event firing
  9.     var empty_cart_page_delay = 500;
  10.  
  11.     // Continue shopping buttons CSS selectors
  12.     // (you can remove the ones that you don't want to change behavior for)
  13.     var buttons = [
  14.       'button.ecwid-productBrowser-cart-continueShoppingButton', // Cart page
  15.       'div.ecwid-productBrowser-cart-emptyCartPanel button.gwt-Button', // Empty cart page
  16.       'button.ecwid-ContinueShoppingButton-Invoice', // Order confirmation page
  17.       'div.ecwid-productBrowser-search-ContinueShoppingButtonContainer button.gwt-Button', // Search results page
  18.       'div.ecwid-Account-ContinueShoppingButtonContainer button.gwt-Button', // 'My account' pages
  19.       'div.ecwid-productBrowser-details div.ecwid-ContinueShoppingButton' //Product page
  20.     ];
  21.  
  22.     // Pages (Ecwid.Page.type) where buttons should be customized
  23.     // (you can remove the pages that you don't want to change the buttons on)
  24.     var pages = [
  25.         'CART',
  26.         'SEARCH',
  27.         'ORDER_CONFIRMATION',        
  28.         'ACCOUNT_SETTINGS',
  29.         'ORDERS',
  30.         'ADDRESS_BOOK'
  31.     ];
  32.    
  33.     // This function find the continue shoppign button on the page and replace it with a customized one
  34.     var replaceButton = function() {
  35.       var buttonObject = jQuery(buttons.join()).filter(":not('.clone'):visible");        
  36.       if (buttonObject.length) {
  37.         buttonObject.clone().addClass('clone').appendTo(buttonObject.parent()).click(function() {
  38.           Wix.navigateToPage(PAGE_ID);
  39.         });
  40.  
  41.         // Remove the original button
  42.         buttonObject.remove();        
  43.       }
  44.     }
  45.  
  46.     // Replace the button on page loading
  47.     Ecwid.OnPageLoaded.add(function(page) {
  48.       if (jQuery.inArray(page.type, pages) >= 0) {        
  49.         replaceButton();
  50.       }
  51.     });
  52.  
  53.     // Replace the button on the empty cart page after clearing the cart
  54.     // (it doesn't fire onPageLoaded event)
  55.     Ecwid.OnCartChanged.add(function(page) {
  56.       setTimeout(replaceButton, empty_cart_page_delay);
  57.     });
  58.  
  59.   });
  60. }
  61. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement