Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var __isp_options = {
  2.     ISP_ENABLE_ADD_TO_CART_AJAX_ANIMATION = true,
  3.     isp_add_to_cart_callback:function(product_id , form_id ) {
  4.         $jquery_isp("svg.icon.icon-cart").after('<div id="CartCount" class="site-header__cart-count"><span>' +
  5.                 ' </span>0<span class="icon__fallback-text medium-up--hide">item</span></div>');
  6.  
  7.         try { document.body.style.cursor = 'initial'; } catch (e) {}
  8.         var cart_selector = ispGetCartSelector();
  9.         try {
  10.             var cart_location_top = (cart_selector) ? cart_selector.offset().top + 10 : 10;
  11.             var cart_location_left = (cart_selector) ? cart_selector.offset().left + 10 : $jquery_isp(window).width() / 2;
  12.         } catch (e) {
  13.             var cart_location_top = 10;
  14.             var cart_location_left= $jquery_isp(window).width() - 10;
  15.         }
  16.         var product_img = $jquery_isp('.isp_grid_product[product_id="' + product_id + '"] img.isp_product_image');
  17.         var z_index = '100';
  18.         // else {
  19.         //     var product_img = $jquery_isp('#isp_product_quick_view_model .isp_quick_view_content_left img');
  20.         //     var z_index = '2147483647';
  21.         // }
  22.         if (product_img) {
  23.             var clone_img = product_img.clone()
  24.                 .offset({
  25.                     top: product_img.offset().top + product_img.height(),
  26.                     left: product_img.offset().left
  27.                 })
  28.                 .css({
  29.                     'opacity': '0.5',
  30.                     'position': 'absolute',
  31.                     'height': '150px',
  32.                     'width': '150px',
  33.                     'z-index': z_index
  34.                 })
  35.                 .appendTo($jquery_isp('body'))
  36.                 .animate({
  37.                     'top': cart_location_top,
  38.                     'left': cart_location_left,
  39.                     'width': 75,
  40.                     'height': 75
  41.                 }, 750);
  42.  
  43.             clone_img.animate({
  44.                 'width': 0,
  45.                 'height': 0
  46.             }, function () {
  47.                 $jquery_isp(this).detach()
  48.             });
  49.         }
  50.         try {  ShopifyAPI.getCart(); } catch (e) {};
  51.         try {
  52.             $jquery_isp.ajax({
  53.                 type           : 'POST',
  54.                 url            : '/cart.js',
  55.                 dataType       : 'json',
  56.                 cache          : false
  57.             })
  58.                 .done(function(data) {
  59.                     var __platform_cartID = $jquery_isp.cookie('cart');
  60.                     if (__platform_cartID != null && __platform_cartID != '') {
  61.                         $jquery_isp.cookie('__isp_cart_last_known', __platform_cartID, { expires: 365, path: '/' });
  62.                         try { localStorage.setItem('__isp_cart', __platform_cartID); }
  63.                         catch (e) {}
  64.                     }
  65.                     $jquery_isp('.cart-count').text(data.item_count);
  66.                 })
  67.                 .fail(function(jqXHR, textStatus) {
  68.                 });
  69.         } catch (e) {}
  70.     }
  71.  
  72. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement