Advertisement
Guest User

Untitled

a guest
Mar 31st, 2020
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const more_swatches = 2;
  2. const country_code = "ITA";
  3.  
  4. const isp_translations = {
  5.     quick_view_button: {
  6.         "UK": "Quick View",
  7.         "AUS": "Quick View",
  8.         "USA" : "Quick View",
  9.         "CH": "Quick View", //swiss
  10.         "FR": "Voir rapide", //french
  11.         "GR": "Schnellansicht", //german
  12.         "ITA": "Visualizza veloce", //italian
  13.         "JP": "クイックビュー", // japanese
  14.         "TH": "มุมมองด่วน", //Thai
  15.     },
  16.     add_to_cart_button: {
  17.         "UK": "Add to Basket",
  18.         "AUS": "Add to Basket",
  19.         "USA" : "Add to Cart",
  20.         "CH": "Add to Basket", //swiss
  21.         "FR": "Ajouter Au Panier", //french
  22.         "GR": "Zum Warenkorb Hinzufugen", //german
  23.         "ITA": "Aggiungi Al Carrello", //italian
  24.         "JP": "バスケットに追加", // japanese
  25.         "TH": "เพิ่มในตะกร้า", //Thai
  26.     },
  27.     color_option_name:{
  28.         "UK": "Colour",
  29.         "AUS": "Colour",
  30.         "USA" : "Color",
  31.         "CH": "Colour", //swiss
  32.         "FR": "Couleur", //french
  33.         "GR": "Farbe", //german
  34.         "ITA": "Colore", //italian
  35.         "JP": "色", // japanese
  36.         "TH": "สี", //Thai
  37.     },
  38.     view_more_button_name: {
  39.         "UK": "View More",
  40.         "AUS": "View More",
  41.         "USA" : "View More",
  42.         "CH": "View More", //swiss
  43.         "FR": "Voir plus", //french
  44.         "GR": "Mehr sehen", //german
  45.         "ITA": "Vedi di più", //italian
  46.         "JP": "もっと見る", // japanese
  47.         "TH": "ดูเพิ่มเติม", //Thai
  48.     }
  49. };
  50.  
  51.  
  52. var __isp_options = {
  53.     isp_serp_callback: function () {
  54.         //change add to cart text for quick view
  55.         ISP_ADD_TO_CART_TEXT = isp_translations.add_to_cart_button[country_code];
  56.         //change add to cart text for serp
  57.         $('.isp_add_to_cart_form > input[type=submit]').attr('value',ISP_ADD_TO_CART_TEXT);
  58.  
  59.         $(".isp_grid_product").each(function () {
  60.  
  61.             // show collapsed swatches
  62.             $(this).find('.isp_product_color_swatch_pop_up span').each(function () {
  63.                 if ($(this).parents(".isp_product_color_swatch_pop_up").find(".moved").length === more_swatches) {
  64.                     return false; //stop loop
  65.                 }
  66.                 $(this).addClass("moved");
  67.                 $(this).parents(".isp_product_color_swatch").find(".extra_swatch_text").before($jquery_isp(this));
  68.             });
  69.             let pop_ups = $(this).find(".isp_product_color_swatch_pop_up span").length;
  70.             if(pop_ups > 0){
  71.                 $(this).find(".extra_swatch_text").text("+"+pop_ups);
  72.             } else {
  73.                 $(this).find(".extra_swatch_text").hide();
  74.             }
  75.  
  76.             // change add to cart text to quick view
  77.             let product_id = $(this).attr("product_id");
  78.             if($(this).find(".isp_add_to_cart_btn").length > 0 && ISP_PRODUCTS[product_id].vra.length > 1){
  79.                 $(this).find(".isp_add_to_cart_btn").val(isp_translations.quick_view_button[country_code]);
  80.             }
  81.  
  82.             // create custom add to cart button
  83.             if ($(this).find("span.view_product_container").length === 0) {
  84.                 $(this).find(".isp_product_image_wrapper").prepend('<span class="view_product_container">' +
  85.                     '<a class="view_product_btn" href="#" product_id="'+product_id+'" onclick="'+
  86.                     $(this).find(".isp_product_quick_view_button").attr("onclick")+'" >'+isp_translations.quick_view_button[country_code]+'</a></span>');
  87.                 $(this).find(".isp_product_quick_view_button").hide();
  88.             }
  89.         });
  90.     }, isp_serp_quickview_callback: function (product_id) {
  91.         //create custom price container (because price lists are not supported)
  92.         let priceHTML =  $(".isp_grid_product[product_id='"+product_id+"'] .isp_product_price_wrapper").html();
  93.         $(".isp_quick_view_price_wrapper").hide()
  94.                                           .after("<span class='custom_price_container' currency='"+ ISP_SITE_CURRENCY +"'>"+priceHTML+"</span>");
  95.  
  96.          $(".isp_quick_view_container_title").text(isp_translations.color_option_name[country_code]);
  97.  
  98.          //hide info bar if only single children exist
  99.          if($(".isp_quick_view_info_bar").children().length === 1){
  100.              $(".isp_quick_view_info_bar").hide();
  101.          }
  102.  
  103.          //view more button
  104.         const view_more_button = '<button class="isp_custom_view_more_btn" href="'+ISP_PRODUCTS[product_id].u+'">' +
  105.             '<img src="https://acp-magento.appspot.com/images/isp_ico-AllInfo.png">'+isp_translations.view_more_button_name[country_code]+'</button>';
  106.          $(".isp_view_full_details").replaceWith(view_more_button);
  107.     }
  108. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement