PageSourceSearch

https://peicannabiscorp.com/wp-content/plugins/WooCommerce-Multi-L…/js/wcmlim-public.js?ver=4.1.10315096341

js peicannabiscorp.com collected 2026-10-02 17:28:29 UTC 16,285 bytes, 426 lines download raw bytes

1import * as alies_localization from "./wcmlim_utility/generic/wcmlim_localization.js";
2import * as alies_listOrdering from "./wcmlim_utility/generic/wcmlim_listOrdering.js";
3import * as alies_sc_listOrdering from "./wcmlim_utility/generic/wcmlim_sc_listOrdering.js";
4//import * as alies_getcookies from "./wcmlim_utility/generic/wcmlim_getcookies.js";
5//import * as alies_setcookies from "./wcmlim_utility/generic/wcmlim_setcookies.js";
6import * as alies_mapWidget from "./wcmlim_utility/generic/wcmlim_map_widget.js";
7import * as alies_selectLocation from "./wcmlim_utility/generic/wcmlim_select_location.js";
8// import * as alies_showPosition from "./wcmlim_utility/generic/wcmlim_show_possition.js";
9import * as alies_GlobalMapList from "./wcmlim_utility/generic/wcmlim_global_maplist.js";
10import * as alies_setLocation from "./wcmlim_utility/generic/wcmlim_set_location.js";
11import * as alies_cookieExists from "./wcmlim_utility/generic/wcmlim_cookie_exists.js";
12import * as alies_VariationIdCheck from "./wcmlim_utility/generic/wcmlim_variation_check.js";
13import * as alies_CommonFunction from "./wcmlim_utility/generic/wcmlim_common_functions.js";
14import * as alies_ChangeLc from "./wcmlim_utility/generic/wcmlim_change_lc_select.js";
15import * as alies_SubmitPostcodeProduct from "./wcmlim_utility/generic/wcmlim_submit_postcode_product.js";
16
17// Access the localized product data
18const currentProductId = wcmlim_product_data.product_id;
19
20
21var localization = alies_localization.wcmlim_localization();
22
23//import {test} from "./wcmlim_utlity/generic/wcmlim_localization.js";
24
25/**
26 * Retrieves the value of a specified cookie by name.
27 *
28 * @param {string} name - The name of the cookie to retrieve.
29 * @returns {string|null} The value of the cookie, or null if the cookie does not exist.
30 */
31function getCookie(name) {
32  var dc = document.cookie;
33  var prefix = name + "=";
34  var begin = dc.indexOf("; " + prefix);
35  if (begin == -1) {
36      begin = dc.indexOf(prefix);
37      if (begin != 0) return null;
38  }
39  else
40  {
41      begin += 2;
42      var end = document.cookie.indexOf(";", begin);
43      if (end == -1) {
44      end = dc.length;
45      }
46  }
47  // because unescape has been deprecated, replaced with decodeURI
48  //return unescape(dc.substring(begin + prefix.length, end));
49  return decodeURI(dc.substring(begin + prefix.length, end));
50} 
51
52/**
53 * Updates the quantity input field based on the selected location.
54 *
55 * @param {string} location - The selected location.
56 * @param {number} quantity - The quantity to set.
57 */
58function wcmlim_set_quantity_input(location){
59  const variationId = jQuery("input.variation_id").val();
60  jQuery
61  .ajax({
62    url: localization.ajaxurl,
63    type: "post",
64    data: {
65      currentProductId: currentProductId,
66      variationId: variationId,
67      selectedLocation: location,
68      action: "wcmlim_get_quantity_attributes",
69    },
70    success: function (response) {
71      console.log("response : ",response);
72      if (response.data.backorder) {
73        jQuery(".quantity input").val(1).attr("max", '').prop('disabled', false);
74        jQuery(".single_add_to_cart_button").show();
75        jQuery(".single_add_to_cart_button").removeClass("disabled");
76        jQuery(".input-text").show();
77        jQuery(".quantity").show();
78        jQuery("#globMsg").hide();
79        jQuery("#losm").hide();
80        jQuery(".qty").removeAttr("max");
81        jQuery(".stock").hide();
82      } else if (response.data.backorder == false && response.data.stock <= 0) {
83        jQuery(".quantity input").val(0).attr("max", 0).prop('disabled', true);
84        jQuery(".single_add_to_cart_button").hide();
85        jQuery(".quantity").hide();
86        jQuery("#globMsg").hide();
87        jQuery("#losm").show();
88        // add stock status message for location if not there
89        if (!response.data.is_prodict_variable && location != -1) {
90          if (jQuery("#losm").length === 0) {
91            jQuery("<p id='losm'> " + (response.data.soldout || "Out of Stock") + "</p>").insertAfter(".Wcmlim_prefloc_sel");
92          }
93        }
94      } else {
95        jQuery(".quantity input").val(1).attr("max", response.data.stock).prop('disabled', false);
96        jQuery(".single_add_to_cart_button").removeClass("disabled");
97        jQuery("#globMsg").show();
98        jQuery("#losm").hide();
99        // add stock status message for location if not there
100        if (!response.data.is_prodict_variable && location != -1) {
101          if (jQuery("#globMsg").length === 0) {
102            jQuery("<p id='globMsg'> <b>" + response.data.stock + "</b> " + response.data.instock + "</p>").insertAfter(".Wcmlim_prefloc_sel");
103          }
104        }
105      }
106    }
107  });
108}
109jQuery(document).ready(($) => {
110  $.noConflict();
111  alies_CommonFunction.Hide_OOS_Product_Allover();
112
113  alies_CommonFunction.NearbyLocationFn();
114
115  alies_listOrdering.listOrdering();
116  alies_sc_listOrdering.sc_listOrdering();
117  alies_mapWidget.mapWidget("elementIdGlobalMap", "rangeInput", "my_current_location");
118  alies_mapWidget.mapWidget("elementIdGlobalMaplist", "rangeInputList", "my_current_location_list");
119  alies_GlobalMapList.GlobalMapList("elementIdGlobalMap", "rangeInput");
120  alies_GlobalMapList.GlobalMapList("elementIdGlobalMaplist", "rangeInputList");
121  alies_GlobalMapList.rangeInputCallback("rangeInput");
122  alies_GlobalMapList.rangeInputCallback("rangeInputList");
123
124  alies_CommonFunction.autodetectFn();
125
126  alies_CommonFunction.Restricted_Location();
127  alies_cookieExists.CookieExists();
128  alies_VariationIdCheck.variationIdExists();
129  alies_CommonFunction.isLocationsGroupFn();
130
131  // get selected location from cookie
132  var selectedLocation = getCookie('wcmlim_selected_location');
133
134  $("#select_location").on("change", function (e) {
135   var value = $(this).find(":selected").val();
136   
137   jQuery
138   .ajax({
139     url: localization.ajaxurl,
140     type: "post",
141     data: {
142       loc_key: value,
143       action: "wcmlim_set_location_on_change",
144      }, // run after location change
145      success: function(response) {
146        if (response.data == "success") {
147          // set the quanity input value and attribute according to location
148          wcmlim_set_quantity_input(value);
149          if(selectedLocation != value){
150            selectedLocation = value;
151          }
152        }
153      }
154    });
155
156    if ($(".wclimadvlist").length < 1) {
157      alies_selectLocation.select_location(this);
158    }
159  });
160
161  //document.addEventListener('DOMContentLoaded', function () {
162    // Select all the location stock cards
163    const locationCardElements = document.querySelectorAll('.location-stock-card');
164
165    locationCardElements.forEach(function (card, index) {
166        // Add a click event listener to each card
167        card.addEventListener('click', function () {
168            // Remove the 'selected' class from all cards
169            locationCardElements.forEach(function (innerCard) {
170                innerCard.classList.remove('selected');
171            });
172
173            // Add the 'selected' class to the clicked card
174            card.classList.add('selected');
175
176            // Pass the location index (key) as an integer
177            const locationKey = index;  // Use the index of the card in the loop as the key
178
179            // Log the location key (index)
180            console.log('Selected Location Key (Integer):', locationKey);
181
182            // Pass location key as an integer to AJAX action
183            jQuery.ajax({
184                url: localization.ajaxurl, // Adjust to your localized URL
185                type: "post",
186                data: {
187                    loc_key: locationKey, // Pass the location key here as an integer
188                    action: "wcmlim_set_location_on_change", // Your action
189                },
190                success: function(response) {
191                    // Optionally handle the response if needed
192                    console.log('Location updated:', response);
193                }
194            });
195        });
196    });
197//});
198
199
200  let loader = alies_CommonFunction.loaderhtml();
201  alies_SubmitPostcodeProduct.submitPostcodeProduct(loader);
202
203  /**
204   * Pincode change.
205   */
206  $(document).on("click", "[data-wpzc-form-open]", (e) => {
207    e.preventDefault();
208    $(".class_post_code").val("");
209    $(".postcode-checker-change").hide();
210    $(".postcode-location-distance").hide();
211    $(".postcode-checker-div")
212      .removeClass("postcode-checker-div-hide")
213      .addClass("postcode-checker-div-show");
214    $(".postcode-checker-response").empty();
215  });
216
217  alies_ChangeLc.ChangeLcSelectWithLocation();
218  alies_ChangeLc.ChangeLc_Select();
219  alies_CommonFunction.wcmlim_locwid_dd();
220  alies_CommonFunction.post_code_checker_common("class_post_code");
221  alies_CommonFunction.post_code_checker_common("class_post_code_global");
222
223  $(document).on("click", "#submit_postcode_global", function (e) {
224    e.preventDefault();
225    var val = $(this)
226      .closest("div.wcmlim_form_box")
227      .find("input[name='post_code_global']")
228      .val();
229    if (val) {
230      alies_setLocation.setLocation(val);
231    } else {
232      alies_setLocation.setLocation();
233    }
234
235  });
236
237
238
239
240
241  $("input[type=radio][name=select_location]").change(function () {
242    var stockQt = $("#select_location")
243      .find("option:selected")
244      .attr("data-lc-qty");
245    var text_qty = document.getElementsByClassName("qty")[0].value;
246    const boStatus = $("#backorderAllowed").val();
247
248    if (boStatus != 1) {
249      if (stockQt < text_qty) {
250        $(".qty").attr({ max: stockQt });
251        document.getElementById("lc_qty").value = stockQt;
252        document.getElementsByClassName("qty")[0].value = 1;
253      } else {
254        $(".qty").attr({ max: stockQt });
255        document.getElementById("lc_qty").value = stockQt;
256      }
257    }
258  });
259
260  $("#select_location").on("change", function () {
261    var addcartid = $(this).data("lc-id");
262    var term_key = $(this).val();
263    var product_simple = jQuery('.single_add_to_cart_button').val();
264    var product_vid = jQuery("input.variation_id").val();
265    var prodsaleprice = $(this).find(':selected').data("lc-sale-price");
266    var prodcity = $(this).find(':selected').data("lc-city");
267    var productprice = productprice ? prodregularprice : prodsaleprice;
268    var product_qty = $(".qty").val();
269    var prodregularprice = $(this).find(':selected').data("lc-regular-price");
270    var prod_backorder = $(this).find(':selected').data("lc-backorder");
271    if (localization.isBackorderOn == "on") {
272      $("#globMsg").hide();
273      $("#losm").hide();
274      $.ajax({
275        url: localization.ajaxurl,
276        type: "post",
277        data: {
278          action: "wcmlim_backorder4el",
279          term_key: term_key,
280          addcartid: addcartid,
281          prodregularprice: prodregularprice,
282          prodsaleprice: prodsaleprice,
283          productprice: productprice,
284          product_qty: product_qty,
285          prodcity: prodcity,
286          product_vid: product_vid,
287          product_simple: product_simple,
288        },
289        success(response) {
290          if(response ==""){
291            $(".single_add_to_cart_button").hide();
292            $(".quantity").hide();
293          }
294          if (response == "show_btn" || prod_backorder == "yes") {
295            var quantityInput = document.getElementsByName('quantity')[0];
296
297            $(".single_add_to_cart_button").show();
298            $(".single_add_to_cart_button").removeClass("disabled");
299            $(".input-text").show();
300            $(".quantity").show();
301            $(".qty").removeAttr("max");
302            $("#losm").hide();
303            $(".stock").hide();
304            $("#globMsg").hide();
305
306            // Create a new input element with type "number"
307            var newInput = document.createElement('input');
308            newInput.type = 'number';
309            newInput.className = quantityInput.className; // Copy classes
310            newInput.name = quantityInput.name;
311            newInput.value = quantityInput.value;
312            newInput.setAttribute('aria-label', quantityInput.getAttribute('aria-label'));
313            newInput.setAttribute('size', quantityInput.getAttribute('size'));
314            newInput.setAttribute('min', quantityInput.getAttribute('min'));
315            newInput.setAttribute('step', quantityInput.getAttribute('step'));
316            newInput.setAttribute('placeholder', quantityInput.getAttribute('placeholder'));
317            newInput.setAttribute('inputmode', quantityInput.getAttribute('inputmode'));
318            newInput.setAttribute('autocomplete', quantityInput.getAttribute('autocomplete'));
319            newInput.style = quantityInput.style; // Copy styles
320
321            // Replace the existing input with the new one
322            quantityInput.parentNode.replaceChild(newInput, quantityInput);
323          }
324          else {
325            //console.log(response);
326            if (response == "ofs") {
327              $(".single_add_to_cart_button").addClass("disabled");
328              $("#losm").show();
329            }
330            if (response == "instk") {
331              $(".single_add_to_cart_button").removeClass("disabled");
332              $("#losm").hide();
333              $(".stock").show();
334              $("#globMsg").show();
335            } else {
336              $("#globMsg").show();
337            }
338          }
339        },
340      });
341    }
342  });
343  //trigger change event after 5 second
344  setTimeout(function () {
345    $("#select_location").trigger("change");
346  }, 2000);
347
348
349  //removed as allowed specific location is default
350
351  $(document).ready(function () {
352    //fetch product name of current selected item
353    function getProductName(button) {
354      return jQuery(button).closest('.product-wrapper').find('h3.wd-entities-title').text().trim();
355    }
356    //on click of +/-/add to cart trigger action for shop page
357    jQuery('.wd-add-btn-replace').on('click', '.plus, .minus,.add_to_cart_button.wcmlim_ajax_add_to_cart', function () {
358
359      var quantityInput = jQuery(this).closest('.wd-add-btn-replace').find('.input-text.qty.text');
360      var locationQty = jQuery(this).closest('.wd-add-btn-replace').find('a.add_to_cart_button').data('location_qty');
361      var locationName = jQuery(this).closest('.wd-add-btn-replace').find('a.add_to_cart_button').data('selected_location');
362      var productName = getProductName(this);
363
364      var enteredQuantity = parseInt(quantityInput.val()); // Get the entered quantity
365
366      quantityInput.attr('max', locationQty, locationName);
367
368      // Check if the entered quantity is less than 1
369      if (enteredQuantity < 1) {
370        Swal.fire({ "icon": "error", "text": "Quantity cannot be 0." })
371        return;
372      }
373
374      // Check if the entered quantity exceeds the maximum allowed value
375      if (enteredQuantity > locationQty) {
376        Swal.fire({ "icon": "error", "text": "Sorry, we do not have enough <strong>" + productName + "</strong> in stock to fulfill your order (" + locationQty + " available) for " + locationName + ". We apologize for any inconvenience caused." })
377        return;
378      }
379
380    });
381
382    setTimeout(function () {
383      if (jQuery(".variations").length > 0) {
384        $(".variations").trigger("click");
385      }
386    }, 2000);
387  });
388
389  // hide location dropdwon variation
390  alies_CommonFunction.hideDropdown();
391  // code -end
392});
393jQuery(document).ready(function ($) {
394  if (wcmlim_public.hideDetailsOnHover) {
395    // Apply the CSS to hide the element on hover using jQuery
396    $('#wcmlim_select_or_dropdown').hover(
397      function () { // Mouse over
398        $(this).find('.quantity').hide(); // Corrected class selectors
399      },
400      function () { // Mouse out
401        $(this).find('.quantity').show(); // Corrected class selectors
402      }
403    );
404  }
405  /* AST Code for diable the Apply button Starts */
406  var zipcode_val = $("#elementIdGlobal").val();
407  $("#elementIdGlobal").keyup(function () {
408    zipcode_val = $(this).val();
409    if (zipcode_val == "") {
410      $("#submit_postcode_global").attr("disabled", true);
411    } else {
412      $("#submit_postcode_global").attr("disabled", false);
413    }
414  });
415
416 
417  /* AST Code for diable the Apply button End */
418
419  var hiddenValue = jQuery('input[name="global_postal_location"]').val();
420    
421  // Set the retrieved value as the placeholder for the text input
422  jQuery('input[name="post_code_global"]').attr('placeholder', hiddenValue);
423});
424
425
426

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.