Advertisement
Guest User

Untitled

a guest
Mar 29th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const more_swatches = 2;
  2.  
  3. const isp_translations = {
  4.     quick_view_button: {
  5.         "UK": "Quick View",
  6.         "AUS": "Quick View",
  7.         "USA" : "Quick View",
  8.         "CH": "Quick View", //swiss
  9.         "FR": "Voir rapide", //french
  10.         "GR": " Schnellansicht", //german
  11.         "ITA": "Visualizza veloce", //italian
  12.         "JP": "クイックビュー", // japanese
  13.         "TH": "มุมมองด่วน", //Thai
  14.     },
  15.     add_to_cart_button: {
  16.         "UK": "Add to Basket",
  17.         "AUS": "Add to Basket",
  18.         "USA" : "Add to Cart",
  19.         "CH": "Add to Basket", //swiss
  20.         "FR": "Ajouter Au Panier", //french
  21.         "GR": "Zum Warenkorb Hinzufugen", //german
  22.         "ITA": "Aggiungi Al Carrello", //italian
  23.         "JP": "バスケットに追加", // japanese
  24.         "TH": "เพิ่มในตะกร้า", //Thai
  25.     },
  26.     color_option_name:{
  27.         "UK": "Colour",
  28.         "AUS": "Colour",
  29.         "USA" : "Color",
  30.         "CH": "Colour", //swiss
  31.         "FR": "Couleur", //french
  32.         "GR": "Farbe", //german
  33.         "ITA": "Colore", //italian
  34.         "JP": "色", // japanese
  35.         "TH": "สี", //Thai
  36.     }
  37. };
  38.  
  39.  
  40. var __isp_options = {
  41.     isp_serp_callback: function () {
  42.         ISP_ADD_TO_CART_TEXT = isp_translations.add_to_cart_button[getSiteCountryCode()];
  43.         $('.isp_add_to_cart_form > input[type=submit]').attr('value',ISP_ADD_TO_CART_TEXT);
  44.  
  45.         $(".isp_grid_product").each(function () {
  46.             $(this).find('.isp_product_color_swatch_pop_up span').each(function () {
  47.                 if ($(this).parents(".isp_product_color_swatch_pop_up").find(".moved").length === more_swatches) {
  48.                     return false; //stop loop
  49.                 }
  50.                 $(this).addClass("moved");
  51.                 $(this).parents(".isp_product_color_swatch").find(".extra_swatch_text").before($jquery_isp(this));
  52.             });
  53.             let pop_ups = $(this).find(".isp_product_color_swatch_pop_up span").length;
  54.             if(pop_ups > 0){
  55.                 $(this).find(".extra_swatch_text").text("+"+pop_ups);
  56.             } else {
  57.                 $(this).find(".extra_swatch_text").hide();
  58.             }
  59.  
  60.             let product_id = $(this).attr("product_id");
  61.             if($(this).find(".isp_add_to_cart_btn").length > 0 && ISP_PRODUCTS[product_id].vra.length > 1){
  62.                 $(this).find(".isp_add_to_cart_btn").val("Quick View");
  63.             }
  64.  
  65.             if ($(this).find("span.view_product_container").length === 0) {
  66.                 $(this).find(".isp_product_image_wrapper").prepend('<span class="view_product_container">' +
  67.                     '<a class="view_product_btn" href="#" product_id="'+product_id+'" onclick="'+
  68.                     $(this).find(".isp_product_quick_view_button").attr("onclick")+'" >'+isp_translations.quick_view_button[getSiteCountryCode()]+'</a></span>');
  69.                 $(this).find(".isp_product_quick_view_button").hide();
  70.             }
  71.         });
  72.     }, isp_serp_quickview_callback: function (product_id) {
  73.         let priceHTML =  $(".isp_grid_product[product_id='"+product_id+"'] .isp_product_price_wrapper").html();
  74.         $(".isp_quick_view_price_wrapper").hide()
  75.                                           .after("<span class='custom_price_container' currency='"+ ISP_SITE_CURRENCY +"'>"+priceHTML+"</span>");
  76.  
  77.          $(".isp_quick_view_container_title").text(isp_translations.color_option_name[getSiteCountryCode()]);
  78.  
  79.          if($(".isp_quick_view_info_bar").children().length === 1){
  80.              $(".isp_quick_view_info_bar").hide();
  81.          }
  82.     }
  83. };
  84.  
  85. function getSiteCountryCode() {
  86.     let country = window.location.href;
  87.     if(country.indexOf("japan") > -1){
  88.         return "JP";
  89.     } else if(country.indexOf("thailand") > -1){
  90.         return "TH";
  91.     } else if(country.indexOf("australia") > -1){
  92.         return "AUS";
  93.     } else if (country.indexOf("france") > -1){
  94.         return "FR";
  95.     } else if(country.indexOf("germany") > -1){
  96.         return "GR";
  97.     } else if(country.indexOf("italy") > -1){
  98.         return "IT";
  99.     } else if(country.indexOf(".ch") > -1){
  100.         return "CH";
  101.     } else if (country.indexOf("usa") > -1){
  102.         return "USA";
  103.     } else {
  104.         return "UK";
  105.     }
  106. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement