Advertisement
RiQ363

Untitled

Mar 20th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
HTML 2.57 KB | None | 0 0
  1. <!-- An HTML/Javascript code snippet for Ecwid to redirect continue shopping buttons to a custom page -->
  2. <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
  3. <script>
  4. if (typeof(Ecwid) == 'object') {
  5.   Ecwid.OnAPILoaded.add(function() {
  6.     // Redirect address. Change it to the URL of page where you want to redirect your customers.
  7.     // You can use absolute or relative addresses, e.g. 'index.html', 'http://google.com'
  8.     var continueShoppingRedirect = "http://i-m.mx/inesott/inesott/coleccion.html";
  9.  
  10.     // Delay (ms), which is necessary for the empty cart page to appear after onCartChange event firing
  11.     var empty_cart_page_delay = 500;
  12.  
  13.     // Continue shopping buttons CSS selectors
  14.     // (you can remove the ones that you don't want to change behavior for)
  15.     var buttons = [
  16.       'button.ecwid-productBrowser-cart-continueShoppingButton', // Cart page
  17.       'div.ecwid-productBrowser-cart-emptyCartPanel button.gwt-Button', // Empty cart page
  18.       'button.ecwid-ContinueShoppingButton-Invoice', // Order confirmation page
  19.       'div.ecwid-productBrowser-search-ContinueShoppingButtonContainer button.gwt-Button', // Search results page
  20.       'div.ecwid-Account-ContinueShoppingButtonContainer button.gwt-Button' // 'My account' pages
  21.     ];
  22.  
  23.     // Pages (Ecwid.Page.type) where buttons should be customized
  24.     // (you can remove the pages that you don't want to change the buttons on)
  25.     var pages = [
  26.         'CART',
  27.         'SEARCH',
  28.         'ORDER_CONFIRMATION',        
  29.         'ACCOUNT_SETTINGS',
  30.         'ORDERS',
  31.         'ADDRESS_BOOK'
  32.     ];
  33.    
  34.     // This function find the continue shoppign button on the page and replace it with a customized one
  35.     var replaceButton = function() {
  36.       var buttonObject = jQuery(buttons.join()).filter(":not('.clone'):visible");        
  37.       if (buttonObject.length) {
  38.         buttonObject.clone().addClass('clone').appendTo(buttonObject.parent()).click(function() {
  39.           location.href = continueShoppingRedirect;
  40.         });
  41.  
  42.         // Remove the original button
  43.         buttonObject.remove();        
  44.       }
  45.     }
  46.  
  47.     // Replace the button on page loading
  48.     Ecwid.OnPageLoaded.add(function(page) {
  49.       if (jQuery.inArray(page.type, pages) >= 0) {        
  50.         replaceButton();
  51.       }
  52.     });
  53.  
  54.     // Replace the button on the empty cart page after clearing the cart
  55.     // (it doesn't fire onPageLoaded event)
  56.     Ecwid.OnCartChanged.add(function(page) {
  57.       setTimeout(replaceButton, empty_cart_page_delay);
  58.     });
  59.  
  60.   });
  61. }
  62. </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement