PageSourceSearch

https://electriccityroasting.com/wp-content/plugins/upsell-order-b…ps_ubo_lite_public_script.js?ver=1788878457

js electriccityroasting.com collected 2026-09-26 12:11:01 UTC 47,580 bytes, 1,394 lines download raw bytes

1jQuery(document).ready(function ($) {
2  if (document.querySelector(".woocommerce-order-received")) {
3    // You are on the cart page.
4    $(".wrapup_order_bump").hide();
5  }
6
7  $(document).on("click", ".wps-ob_ta-o-title", function (e) {
8    if ($(e.target).closest(".add_offer_in_cart").length) {
9      return;
10    }
11
12    if (e.wps_ubo_title_click_handled) {
13      return;
14    }
15    e.wps_ubo_title_click_handled = true;
16
17    var bumpButton = $(this).find(".add_offer_in_cart").first();
18    if (!bumpButton.length) {
19      bumpButton = $(this)
20        .closest(".wps_upsell_offer_main_wrapper")
21        .find(".add_offer_in_cart")
22        .first();
23    }
24
25    if (bumpButton.length) {
26      bumpButton.trigger("click");
27    } else {
28      console.log("Element with class .add_offer_in_cart not found.");
29    }
30  });
31
32  
33
34  setTimeout(function () {
35    //Bump Shown on the checkout page code starts here.
36    var wps_is_checkout_block_use =
37      wps_ubo_lite_public.wps_is_checkout_block_use;
38
39    if (
40      wps_is_checkout_block_use &&
41      $("body").hasClass("woocommerce-checkout")
42    ) {
43      if ($(".wrapup_order_bump").length > 0) {
44        var data = $(".wrapup_order_bump").html();
45
46        // ===== LOCATION: Before Place Order =====
47        if (
48          wps_ubo_lite_public.wps_order_bump_location_on_checkout ==
49          "_before_place_order_button"
50        ) {
51          $(".wrapup_order_bump").first().remove();
52          $(".wp-block-woocommerce-checkout-order-summary-block").append(
53            '<div class="wrapup_order_bump">' + data + "</div>"
54          );
55        }
56
57        // ===== LOCATION: After Payment Gateways =====
58        else if (
59          wps_ubo_lite_public.wps_order_bump_location_on_checkout ==
60          "_after_payment_gateways"
61        ) {
62          $(".wrapup_order_bump").first().remove();
63          $(".wc-block-checkout__payment-method").append(
64            '<div class="wrapup_order_bump">' + data + "</div>"
65          );
66        }
67
68        // ===== LOCATION: Before Order Summary =====
69        else if (
70          wps_ubo_lite_public.wps_order_bump_location_on_checkout ==
71          "_before_order_summary"
72        ) {
73          $(".wrapup_order_bump").first().remove();
74          $(
75            ".wp-block-woocommerce-checkout-order-summary-coupon-form-block"
76          ).append('<div class="wrapup_order_bump">' + data + "</div>");
77        }
78
79        // ===== LOCATION: Before Payment Gateways =====
80        else if (
81          wps_ubo_lite_public.wps_order_bump_location_on_checkout ==
82          "_before_payment_gateways"
83        ) {
84          $(".wrapup_order_bump").first().remove();
85          $(".wp-block-woocommerce-checkout").prepend(
86            '<div class="wrapup_order_bump">' + data + "</div>"
87          );
88        }
89      }
90    }
91    //Bump Shown on the checkout page code ends here.
92
93    var wps_is_cart_block_use = wps_ubo_lite_public.wps_is_cart_block_use;
94    if (
95      "on" == wps_ubo_lite_public.wps_enable_cart_upsell &&
96      wps_is_cart_block_use &&
97      document.querySelector(".woocommerce-cart")
98    ) {
99      console.log("Cart Block is used");
100      console.log(wps_ubo_lite_public.wps_order_bump_location_on_cart);
101      if (jQuery(".wrapup_order_bump").length > 0) {
102        var data = jQuery(".wrapup_order_bump").html();
103        if (
104          "woocommerce_after_cart_totals" ==
105          wps_ubo_lite_public.wps_order_bump_location_on_cart
106        ) {
107          jQuery(".wp-block-woocommerce-cart-totals-block").append(
108            '<div class = "wrapup_order_bump">' + data + "</div>"
109          );
110          $(".wrapup_order_bump").first().remove();
111        } else if (
112          "woocommerce_cart_collaterals" ==
113          wps_ubo_lite_public.wps_order_bump_location_on_cart
114        ) {
115          jQuery(".wc-block-components-totals-footer-item").append(
116            '<div class = "wrapup_order_bump">' + data + "</div>"
117          );
118          $(".wrapup_order_bump").first().remove();
119        } else if (
120          "woocommerce_before_cart_totals" ==
121          wps_ubo_lite_public.wps_order_bump_location_on_cart
122        ) {
123          jQuery(
124            jQuery(".wp-block-woocommerce-cart-line-items-block").parent()
125          ).append('<div class = "wrapup_order_bump">' + data + "</div>");
126          $(".wrapup_order_bump").first().remove();
127        }
128      }
129    }
130    //For the new template 10 js.
131    var wps_ob_con = jQuery(".wps-ob-st");
132    if (wps_ob_con.width() < 396) {
133      wps_ob_con.addClass("ob_cont-full");
134    }
135  }, 1000);
136
137  $(document).on("click", ".wc-block-cart-item__remove-link", function () {
138    setTimeout(function () {
139      location.reload();
140    }, 2000);
141  });
142
143  if (
144    "yes" == wps_ubo_lite_public.wps_popup_body_class &&
145    null == wps_ubo_lite_public.wps_popup_body_class
146  ) {
147    var body = document.body;
148
149    body.classList.remove("wps_body_class_popup");
150  }
151
152  setInterval(function () {
153    $(".wps_product_gallery_wrapper").slick({
154      dots: false,
155      arrows: true,
156      slidesToShow: 1,
157      variableWidth: true,
158      infinite: true,
159      responsive: [
160        {
161          breakpoint: 1080,
162          settings: {
163            arrows: false,
164          },
165        },
166      ],
167    });
168
169    var gallery_img = $(".wps_product_gallery_wrapper img");
170    gallery_img.on("click", function () {
171      var gallery_img_clone = $(this).clone();
172      $(".wps_product_gallery_img_focus_wrapper").show();
173      $(".wps_product_gallery_img_focus_wrapper_box").empty();
174      $(gallery_img_clone).appendTo(
175        ".wps_product_gallery_img_focus_wrapper_box"
176      );
177      $(".wps_product_gallery_img_focus_wrapper .close").on(
178        "click",
179        function () {
180          $(".wps_product_gallery_img_focus_wrapper").hide();
181        }
182      );
183    });
184  }, 1000);
185
186  $(document).on("click", ".wps_product_info", function () {
187    $(this).toggleClass("accordian--active");
188    $(this).next("p").slideToggle();
189  });
190
191  function getNum(val) {
192    if (isNaN(val)) {
193      return 0;
194    }
195    return val;
196  }
197
198  if (wps_ubo_lite_public.hasOwnProperty("check_if_reload")) {
199    if ("reload" === wps_ubo_lite_public.check_if_reload) {
200      // Nothing to do.
201    } else {
202      if (wps_ubo_lite_public.hasOwnProperty("timer")) {
203        var columns = wps_ubo_lite_public.check_if_reload;
204        var rows = wps_ubo_lite_public.timer;
205        var result = [];
206        $.each(rows, function (index, value) {
207          if (columns.indexOf(parseInt(index)) >= 0) {
208            result[index] = value;
209          }
210        });
211
212        setTimeout(function () {
213          setInterval(function () {
214            for (var key in result) {
215              if ("yes" === result[key].enabled) {
216                var deadline = new Date(result[key].counter).getTime();
217                var now = new Date().getTime();
218                var t = deadline - now;
219                var days = Math.floor(t / (1000 * 60 * 60 * 24));
220                var hours = Math.floor(
221                  (t % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)
222                );
223                var minutes = Math.floor((t % (1000 * 60 * 60)) / (1000 * 60));
224                var seconds = Math.floor((t % (1000 * 60)) / 1000);
225                document.getElementById("wps_day_time_" + key).innerHTML =
226                  getNum(days);
227                document.getElementById("wps_hour_time_" + key).innerHTML =
228                  getNum(hours);
229                document.getElementById("wps_min_time_" + key).innerHTML =
230                  getNum(minutes);
231                document.getElementById("wps_sec_time_" + key).innerHTML =
232                  getNum(seconds);
233
234                const element = document.getElementById("wps_timer" + key);
235                const element_error = document.getElementById(
236                  "expired_message" + key
237                );
238                element.style.backgroundColor = "white";
239                element_error.style.backgroundColor = "white";
240                if (t < 0) {
241                  $("#wps_timer" + key).css({ display: "none" });
242                  document.getElementById("expired_message" + key).innerHTML =
243                    "EXPIRED";
244                  document.getElementById(
245                    "wps_checkbox_offer" + key
246                  ).disabled = true;
247                  $("#wps_button_id_" + key).hide();
248                  $("#expired_message" + key)
249                    .parent()
250                    .css("pointer-events", "none");
251                }
252              }
253            }
254          }, 1000);
255        }, 1000);
256      }
257    }
258  }
259
260  // When bump is prepared we will get this data.
261  var bump_id = "";
262  var bump_discount = "";
263  var bump_target_cart_key = "";
264  var default_image = "";
265  var default_price = "";
266  var order_bump_index = "";
267  var order_bump_id = "";
268  var smart_offer_upgrade = "";
269  var selected_order_bump = "";
270  var selected_order_bump_popup = "";
271
272  function wps_ubo_lite_intant_zoom_img(selected_order_bump_popup) {
273    if (wps_ubo_lite_public.mobile_view != 1) {
274      selected_order_bump_popup
275        .find(".woocommerce-product-gallery__image")
276        .zoom();
277    }
278  }
279
280  function wps_is_cart_page_context() {
281    return $("body").hasClass("woocommerce-cart");
282  }
283
284  const triggerRemoveOffer = (order_bump_index, order_bump_id) => {
285    //Getting Current theme Name.
286    var wps_current_theme = wps_ubo_lite_public.current_theme;
287
288    // Remove the same product from cart.
289    jQuery.ajax({
290      type: "post",
291      dataType: "json",
292      url: wps_ubo_lite_public.ajaxurl,
293      data: {
294        nonce: wps_ubo_lite_public.auth_nonce,
295        action: "remove_offer_in_cart",
296
297        // Index : index_{ digit }
298        bump_index: order_bump_index,
299        order_bump_id: order_bump_id,
300      },
301
302      success: function (msg) {
303        $("body").trigger("update_checkout");
304        $(document.body).trigger("added_to_cart", {});
305        $(document.body).trigger("update_checkout");
306
307        //Mini-Cart Upadte on Checkout depending upon themes.
308        wps_minicart_update(wps_current_theme);
309
310        $(".wps_ubo_wrapper_" + order_bump_index).css("pointer-events", "all");
311        $(".wps_ubo_wrapper_" + order_bump_index).css("opacity", "1");
312        var body = document.body;
313        body.classList.remove("wps_body_class_popup");
314
315        if (
316          ("Avada" == wps_current_theme ||
317            "Divi" == wps_current_theme ||
318            "Flatsome" == wps_current_theme) &&
319          (wps_ubo_lite_public.wps_silde_cart_plgin_active ||
320            "Betheme" == wps_current_theme)
321        ) {
322          $("html, body").scrollTop(300);
323          location.reload(); //avada and side cart issue fixes.
324        }
325      },
326    });
327  };
328
329  /**
330   * Js to get variation product for "any variation" from dropdown in json format.
331   */
332  var wps_orderbump_any_variation = {};
333  jQuery(document).on(
334    "change",
335    "select.wps_upsell_offer_variation_select",
336    function () {
337      wps_orderbump_any_variation[jQuery(this).attr("id")] = jQuery(this).val();
338    }
339  );
340
341  /**
342   * Process orderbump for variations.
343   *
344   * @param {object} object    Bump object
345   * @param {array}  formdata  Custom form object.
346   */
347  function triggerAddOfferVariation(object, form_data) {
348    // Prevent mulitple clicks on this button.
349    object.prop("disabled", true);
350    order_bump_index = object.attr("offer_bump_index");
351    if (typeof order_bump_index === "undefined") {
352      console.log("order bump not found");
353      return;
354    }
355
356    // Get product Quantity
357    if (
358      object
359        .closest(".wps_bump_popup_select")
360        .find(".wps_bump_name")
361        .attr("data-wps_is_fixed_qty") == "true" &&
362      object
363        .closest(".wps_bump_popup_select")
364        .find(".wps_bump_name")
365        .attr("data-qty_allowed") == "yes"
366    ) {
367      var wps_qty_variable = object
368        .closest(".wps_bump_popup_select")
369        .find(".wps_bump_name")
370        .attr("data-wps_qty");
371    } else if (
372      object
373        .closest(".wps_bump_popup_select")
374        .find(".wps_quantity_input")
375        .val() != undefined &&
376      object
377        .closest(".wps_bump_popup_select")
378        .find(".wps_bump_name")
379        .attr("data-qty_allowed") == "yes" &&
380      object
381        .closest(".wps_bump_popup_select")
382        .find(".wps_bump_name")
383        .attr("data-wps_is_fixed_qty") == "false"
384    ) {
385      var wps_qty_variable = object
386        .closest(".wps_bump_popup_select")
387        .find(".wps_quantity_input")
388        .val();
389    } else {
390      var wps_qty_variable = 1;
391    }
392
393    $value_of_input_field_to_check = object
394      .closest(".wps_bump_popup_select")
395      .find(".wps_quantity_input")
396      .val();
397    $min_attr_value = object
398      .closest(".wps_bump_popup_select")
399      .find(".wps_quantity_input")
400      .attr("min");
401    $max_attr_value = object
402      .closest(".wps_bump_popup_select")
403      .find(".wps_quantity_input")
404      .attr("max");
405
406    if ($min_attr_value != undefined && $min_attr_value != undefined) {
407      if (
408        parseInt($value_of_input_field_to_check) >= parseInt($min_attr_value) &&
409        parseInt($value_of_input_field_to_check) <= parseInt($max_attr_value)
410      ) {
411        var inLimit = "true";
412      } else {
413        alert("Max Limit " + $max_attr_value + " Min Limit " + $min_attr_value);
414        object.prop("checked", false);
415        location.reload();
416        return;
417      }
418    }
419
420    // Order Bump Object.
421    var parent_wrapper_class = ".wps_ubo_wrapper_index_" + order_bump_index;
422    var selected_order_bump = jQuery(parent_wrapper_class);
423
424    //Getting Current theme Name.
425    var wps_current_theme = wps_ubo_lite_public.current_theme;
426
427    // Disable bump div.
428    $(parent_wrapper_class).css("pointer-events", "none");
429    $(parent_wrapper_class).css("opacity", "0.4");
430
431    // Required Data.
432    bump_id = selected_order_bump.find(".offer_shown_id").val();
433    bump_discount = selected_order_bump.find(".offer_shown_discount").val();
434    bump_target_cart_key = selected_order_bump
435      .find(".target_id_cart_key")
436      .val();
437    order_bump_id = selected_order_bump.find(".order_bump_id").val();
438    smart_offer_upgrade = selected_order_bump.find(".order_bump_smo").val();
439
440    var variation_selected = "";
441    jQuery("body")
442      .find(".variation_id_selected")
443      .each(function () {
444        if (object.attr("offer_bump_index") == order_bump_index) {
445          variation_selected = jQuery("input.variation_id_selected").val();
446        }
447      });
448
449    console.log(variation_selected); //No data is coming.);
450
451    jQuery.ajax({
452      type: "post",
453      dataType: "json",
454      url: wps_ubo_lite_public.ajaxurl,
455      data: {
456        nonce: wps_ubo_lite_public.auth_nonce,
457        action: "add_variation_offer_in_cart",
458        id: variation_selected, // variation offer product id.
459        parent_id: bump_id, // variation offer parent product id.
460        wps_orderbump_any_variation: wps_orderbump_any_variation, // variation data from dropdown
461        discount: bump_discount,
462        order_bump_id: order_bump_id,
463        smart_offer_upgrade: smart_offer_upgrade,
464        wps_qty_variable: wps_qty_variable, // Quantity attr
465
466        // Index : { digit }
467        bump_index: order_bump_index,
468        bump_target_cart_key: bump_target_cart_key,
469
470        // Form data if present.
471        form_data: form_data,
472      },
473      success: function (msg) {
474        $("body").removeClass("wps_upsell_variation_pop_up_body");
475        $(".wps_bump_popup_wrapper").css("display", "none");
476        $("body").trigger("update_checkout");
477        $(document.body).trigger("added_to_cart", {});
478        $(document.body).trigger("update_checkout");
479
480        //Mini-Cart Upadte on Checkout depending upon themes.
481        wps_minicart_update(wps_current_theme);
482
483        $(parent_wrapper_class).css("pointer-events", "all");
484        $(parent_wrapper_class).css("opacity", "1");
485        $(".wps_ubo_bump_add_to_cart_button").prop("disabled", false);
486
487        // When Reload is required.
488        if ("subs_reload" == msg) {
489          if (!wps_is_cart_page_context()) {
490            // Scroll Top and Reload.
491            $("html, body").scrollTop(300);
492            location.reload();
493          }
494        }
495
496        var body = document.body;
497        body.classList.remove("wps_body_class_popup");
498      },
499    });
500  }
501
502  /**
503   * Process orderbump.
504   *
505   * @param {object} object    Bump object
506   * @param {array}  formdata  Custom form object.
507   */
508  function triggerAddOffer(object, formdata) {
509    // Get product Quantity
510    if (
511      object
512        .closest(".wps_upsell_offer_main_wrapper")
513        .find(".wps_bump_name")
514        .attr("data-wps_is_fixed_qty") == "true" &&
515      object
516        .closest(".wps_upsell_offer_main_wrapper")
517        .find(".wps_bump_name")
518        .attr("data-qty_allowed") == "yes"
519    ) {
520      var wps_qty_variable = object
521        .closest(".wps_upsell_offer_main_wrapper")
522        .find(".wps_bump_name")
523        .attr("data-wps_qty"); //check whether qty variable or not.
524    } else if (
525      object
526        .closest(".wps_upsell_offer_main_wrapper")
527        .find(".wps_quantity_input")
528        .val() != undefined &&
529      object
530        .closest(".wps_upsell_offer_main_wrapper")
531        .find(".wps_bump_name")
532        .attr("data-qty_allowed") == "yes" &&
533      object
534        .closest(".wps_upsell_offer_main_wrapper")
535        .find(".wps_bump_name")
536        .attr("data-wps_is_fixed_qty") == "false"
537    ) {
538      var wps_qty_variable = object
539        .closest(".wps_upsell_offer_main_wrapper")
540        .find(".wps_quantity_input")
541        .val(); //in these condition we check for min and max quantity.
542    } else {
543      var wps_qty_variable = 1;
544    }
545
546    $value_of_input_field_to_check = object
547      .closest(".wps_upsell_offer_main_wrapper")
548      .find(".wps_quantity_input")
549      .val();
550    $min_attr_value = object
551      .closest(".wps_upsell_offer_main_wrapper")
552      .find(".wps_quantity_input")
553      .attr("min");
554    $max_attr_value = object
555      .closest(".wps_upsell_offer_main_wrapper")
556      .find(".wps_quantity_input")
557      .attr("max");
558    //In Above get max , min and actual inside the input box.
559
560    if ($min_attr_value != undefined && $min_attr_value != undefined) {
561      if (
562        parseInt($value_of_input_field_to_check) >= parseInt($min_attr_value) &&
563        parseInt($value_of_input_field_to_check) <= parseInt($max_attr_value)
564      ) {
565        var inLimit = "true";
566      } else {
567        alert("Max Limit " + $max_attr_value + " Min Limit " + $min_attr_value);
568        object.prop("checked", false);
569        location.reload();
570        return;
571      }
572    } //This will check valida value in the input box.
573
574    order_bump_index = object
575      .closest(".wps_upsell_offer_main_wrapper")
576      .find(".order_bump_index")
577      .val();
578    parent_wrapper_class = ".wps_ubo_wrapper_" + order_bump_index;
579    order_bump_id = object
580      .closest(".wps_upsell_offer_main_wrapper")
581      .find(".order_bump_id")
582      .val();
583
584    // Disable bump div.
585    $(".wps_ubo_wrapper_" + order_bump_index).css("pointer-events", "none");
586    $(".wps_ubo_wrapper_" + order_bump_index).css("opacity", "0.4");
587    if ($(parent_wrapper_class + " .add_offer_in_cart").is(":checked")) {
588      // Get Order Bump variation popup ready.
589      handle_pre_selected_values();
590
591      //Getting Current theme Name.
592      var wps_current_theme = wps_ubo_lite_public.current_theme;
593
594      // Show loader for Variable offers.
595      if (
596        "variable" ==
597        object
598          .closest(".wps_upsell_offer_main_wrapper")
599          .find(".offer_shown_id_type")
600          .val()
601      ) {
602        $(".wps_bump_popup_loader").css("display", "flex");
603      }
604
605      bump_id = object
606        .closest(".wps_upsell_offer_main_wrapper")
607        .find(".offer_shown_id")
608        .val(); // offer product id.
609      bump_discount = object
610        .closest(".wps_upsell_offer_main_wrapper")
611        .find(".offer_shown_discount")
612        .val();
613      bump_target_cart_key = object
614        .closest(".wps_upsell_offer_main_wrapper")
615        .find(".target_id_cart_key")
616        .val();
617      smart_offer_upgrade = object
618        .closest(".wps_upsell_offer_main_wrapper")
619        .find(".order_bump_smo")
620        .val();
621
622      // Add product to cart.
623      jQuery.ajax({
624        type: "post",
625        dataType: "json",
626        url: wps_ubo_lite_public.ajaxurl,
627        data: {
628          nonce: wps_ubo_lite_public.auth_nonce,
629          action: "add_offer_in_cart",
630          id: bump_id, // offer product id.
631          discount: bump_discount,
632          bump_target_cart_key: bump_target_cart_key,
633          order_bump_id: order_bump_id,
634          smart_offer_upgrade: smart_offer_upgrade,
635          wps_qty_variable: wps_qty_variable, // Quantity attr
636
637          // Index : index_{ digit }
638          bump_index: order_bump_index,
639          // Form data.
640          form_data: formdata,
641        },
642
643        success: function (msg) {
644          // For variable product.
645          if (msg["key"] == "true") {
646            variation_popup_index = order_bump_index.replace("index_", "");
647            $(".wps_ubo_price_html_for_variation").html(msg["message"]);
648            $(".wps_bump_popup_loader").css("display", "none");
649            $(".wps_bump_popup_" + variation_popup_index).css(
650              "display",
651              "flex"
652            );
653            $("body").addClass("wps_upsell_variation_pop_up_body");
654
655            // Add zoom to defaut image.
656            selected_order_bump_popup = jQuery(
657              ".wps_bump_popup_" + variation_popup_index
658            );
659            wps_ubo_lite_intant_zoom_img(selected_order_bump_popup);
660
661            if (default_price == "") {
662              default_price = $(".wps_ubo_price_html_for_variation").html();
663            }
664          }
665
666          // For simple Products and Variations.
667          else {
668            $(".wps_bump_popup_loader").css("display", "none");
669            $("body").trigger("update_checkout");
670            $(document.body).trigger("added_to_cart", {});
671            $(document.body).trigger("update_checkout");
672
673            //Mini-Cart Upadte on Checkout depending upon themes.
674            wps_minicart_update(wps_current_theme);
675
676            $(".wps_ubo_wrapper_" + order_bump_index).css(
677              "pointer-events",
678              "all"
679            );
680            $(".wps_ubo_wrapper_" + order_bump_index).css("opacity", "1");
681
682            // When Reload is required.
683            if ("subs_reload" == msg) {
684              if (!wps_is_cart_page_context()) {
685                // Scroll Top and Reload.
686                $("html, body").scrollTop(300);
687                location.reload();
688              }
689            }
690
691            var body = document.body;
692            body.classList.remove("wps_body_class_popup");
693
694            if (
695              ("Avada" == wps_current_theme ||
696                "Divi" == wps_current_theme ||
697                "Flatsome" == wps_current_theme) &&
698              (wps_ubo_lite_public.wps_silde_cart_plgin_active ||
699                "Betheme" == wps_current_theme)
700            ) {
701              if (!wps_is_cart_page_context()) {
702                $("html, body").scrollTop(300);
703                location.reload(); //avada and side cart issue fixes.
704              }
705            }
706          }
707        },
708      });
709    }
710  }
711
712  // Prevent Enter Key Press for checkbox of Order Bump offers.
713  $(document).on("keypress", ".add_offer_in_cart", function (e) {
714    // The enter key code.
715    if (e.which == 13) {
716      e.preventDefault();
717    }
718  });
719
720  /*==========================================================================
721                            Add to cart checkbox click
722    ============================================================================*/
723  /**
724   * CHECKBOX ADD TO CART [ works with simple product and product variations ].
725   */
726  jQuery(document).on("click", ".add_offer_in_cart", function (e) {
727    order_bump_trigger_obj = jQuery(this);
728    order_bump_index = order_bump_trigger_obj
729      .closest(".wps_upsell_offer_main_wrapper")
730      .find(".order_bump_index")
731      .val();
732    parent_wrapper_class = ".wps_ubo_wrapper_" + order_bump_index;
733    order_bump_id = order_bump_trigger_obj
734      .closest(".wps_upsell_offer_main_wrapper")
735      .find(".order_bump_id")
736      .val();
737
738    // When offer is added.
739    if (order_bump_trigger_obj.is(":checked")) {
740      // Check if meta form present.
741      let popup_obj = jQuery("#wps-meta-form-index-" + order_bump_id);
742
743      let index = 0;
744
745      // Meta form available.
746      if (
747        popup_obj.length > 0 &&
748        !popup_obj.hasClass("wps_bump_popup_variable_meta_form")
749      ) {
750        open_custom_form(popup_obj, order_bump_trigger_obj);
751
752        jQuery(".wps-meta-form-submit").on("click", function (e) {
753          e.preventDefault();
754          let data_arr = [];
755          jQuery("#wps-meta-form-index-" + order_bump_id)
756            .find(".wps_ubo_custom_meta_field")
757            .each(function () {
758              let field_obj = {};
759
760              if ("" == jQuery(this).val()) {
761                alert(jQuery(this).attr("name") + " field cannot be empty");
762                return;
763              } else if ("checkbox" == jQuery(this).attr("type")) {
764                // Push the values in an array.
765                field_obj.name = jQuery(this).attr("name");
766                field_obj.value = jQuery(this).prop("checked");
767                data_arr[index] = field_obj;
768                index++;
769              } else {
770                // Push the values in an array.
771                field_obj.name = jQuery(this).attr("name");
772                field_obj.value = jQuery(this).val();
773
774                data_arr[index] = field_obj;
775                index++;
776              }
777            });
778
779          data_arr = data_arr.filter(onlyUnique);
780
781          // All fields are saved!
782          if (
783            data_arr.length ==
784            popup_obj.find(".wps_ubo_custom_meta_field").length
785          ) {
786            // Close popup and send add to cart request.
787            close_custom_form();
788            triggerAddOffer(order_bump_trigger_obj, data_arr);
789          }
790        });
791      } else {
792        triggerAddOffer(jQuery(this), []);
793      }
794    } else {
795      // Remove Offer.
796      triggerRemoveOffer(order_bump_index, order_bump_id);
797    }
798  });
799
800  function onlyUnique(value, index, self) {
801    return self.indexOf(value) === index;
802  }
803
804  /*=======================================================================
805                        Default selection trigger in variations popup.
806    ========================================================================*/
807
808  function handle_pre_selected_values() {
809    var variations = jQuery(".wps_upsell_offer_variation_select");
810    if (variations.length > 0) {
811      var value_exists = false;
812      variations.each(function () {
813        if (jQuery(this).val() !== "") {
814          value_exists = true;
815          return;
816        }
817      });
818
819      if (true == value_exists) {
820        jQuery(".wps_upsell_offer_variation_select").trigger("change");
821      }
822    }
823  }
824
825  function open_custom_form(form_obj, order_bump_obj) {
826    let form_wrap = form_obj.parent().parent().parent().parent();
827    jQuery("body").css("overflow", "hidden");
828    if (jQuery(".wps-g-modal").hasClass("wps-modal--close")) {
829      jQuery(".wps-g-modal").removeClass("wps-modal--close");
830    }
831    form_wrap.addClass("wps-modal--open");
832
833    jQuery(".wps-g-modal__close").on("click", function () {
834      order_bump_obj.prop("checked", false);
835      close_custom_form();
836    });
837  }
838
839  function close_custom_form() {
840    jQuery("body").css("overflow", "auto");
841    jQuery(".wps-g-modal").addClass("wps-modal--close");
842    setTimeout(function () {
843      jQuery(".wps-g-modal").removeClass("wps-modal--open");
844    }, 320);
845  }
846
847  /*=======================================================================
848                        Select the variations in popup.
849    ========================================================================*/
850  /*
851   * POP-UP Select change JS,
852   * To add the price html and image of selected variation in popup.
853   */
854
855  $(document).on("change", ".wps_upsell_offer_variation_select", function (e) {
856    var selected_order_bump_index = $(this).attr("order_bump_index");
857
858    // Order Bump Object.
859    var parent_wrapper_class =
860      ".wps_ubo_wrapper_index_" + selected_order_bump_index;
861    selected_order_bump = jQuery(parent_wrapper_class);
862
863    // Order Bump Popup Object.
864    var popup_wrapper_class = ".wps_bump_popup_" + selected_order_bump_index;
865    selected_order_bump_popup = jQuery(popup_wrapper_class);
866
867    // Fetch selected attributes.
868    var selected_variations = selected_order_bump_popup.find(
869      ".wps_upsell_offer_variation_select"
870    );
871    var attributes_selected = [];
872
873    // Default image handle here.
874    if (default_image == "") {
875      if (
876        selected_order_bump_popup.find("woocommerce-product-gallery__image")
877      ) {
878        default_image = selected_order_bump_popup.find(
879          ".woocommerce-product-gallery__image"
880        );
881      } else {
882        default_image = selected_order_bump_popup.find(
883          ".woocommerce-placeholder"
884        );
885      }
886    }
887
888    for (var i = selected_variations.length - 1; i >= 0; i--) {
889      if (selected_variations[i].value == "") {
890        // Default View on no selection.
891        selected_order_bump_popup
892          .find(".wps_bump_popup_image")
893          .html(default_image);
894        wps_ubo_lite_intant_zoom_img(selected_order_bump_popup);
895        selected_order_bump_popup
896          .find(".wps_ubo_err_waring_for_variation")
897          .css("display", "none");
898        selected_order_bump_popup
899          .find(".wps_ubo_price_html_for_variation")
900          .css("display", "block");
901        selected_order_bump_popup
902          .find(".wps_ubo_bump_add_to_cart_button")
903          .css("display", "none");
904        selected_order_bump_popup
905          .find(".wps_ubo_price_html_for_variation")
906          .html(default_price);
907
908        return;
909      } else {
910        attributes_selected[selected_variations[i].id] =
911          selected_variations[i].value;
912      }
913    }
914
915    /*
916     * Got an array of all selected attribute.
917     * Will run an ajax for search of attributes.
918     * Show price and image.
919     * Will see for variation id and in stock.
920     * Add to cart button will be shown.
921     */
922
923    // Converts attributes array in object.
924    attributes_selected = Object.assign({}, attributes_selected);
925
926    // Required Data.
927    bump_id = selected_order_bump.find(".offer_shown_id").val();
928    bump_discount = selected_order_bump.find(".offer_shown_discount").val();
929    wps_order_bump_id = $(this).attr("order_bump_index");
930
931    jQuery.ajax({
932      type: "post",
933      dataType: "json",
934      url: wps_ubo_lite_public.ajaxurl,
935      data: {
936        nonce: wps_ubo_lite_public.auth_nonce,
937        action: "search_variation_id_by_select",
938        attributes_selected_options: attributes_selected,
939        id: bump_id,
940        discount: bump_discount,
941        wps_order_bump_id,
942      },
943
944      success: function (msg) {
945        if (msg["key"] == "stock") {
946          selected_order_bump_popup
947            .find(".wps_ubo_err_waring_for_variation")
948            .css("display", "flex");
949          selected_order_bump_popup
950            .find(".wps_ubo_price_html_for_variation")
951            .css("display", "none");
952          selected_order_bump_popup
953            .find(".wps_ubo_bump_add_to_cart_button")
954            .css("display", "none");
955
956          selected_order_bump_popup
957            .find(".wps_bump_popup_image")
958            .html(msg["image"]);
959          wps_ubo_lite_intant_zoom_img(selected_order_bump_popup);
960          selected_order_bump_popup
961            .find(".wps_ubo_err_waring_for_variation")
962            .html(msg["message"]);
963        } else if (msg["key"] == "not_available") {
964          selected_order_bump_popup
965            .find(".wps_ubo_err_waring_for_variation")
966            .css("display", "flex");
967          selected_order_bump_popup
968            .find(".wps_ubo_price_html_for_variation")
969            .css("display", "none");
970          selected_order_bump_popup
971            .find(".wps_ubo_bump_add_to_cart_button")
972            .css("display", "none");
973
974          selected_order_bump_popup
975            .find(".wps_bump_popup_image")
976            .html(msg["image"]);
977          wps_ubo_lite_intant_zoom_img(selected_order_bump_popup);
978          selected_order_bump_popup
979            .find(".wps_ubo_err_waring_for_variation")
980            .html(msg["message"]);
981        } else if (!isNaN(msg["key"])) {
982          selected_order_bump_popup
983            .find(".wps_ubo_err_waring_for_variation")
984            .css("display", "none");
985          selected_order_bump_popup
986            .find(".wps_ubo_price_html_for_variation")
987            .css("display", "block");
988          selected_order_bump_popup
989            .find(".wps_ubo_bump_add_to_cart_button")
990            .css("display", "flex");
991
992          selected_order_bump_popup
993            .find(".wps_bump_popup_image")
994            .html(msg["image"]);
995          wps_ubo_lite_intant_zoom_img(selected_order_bump_popup);
996          selected_order_bump_popup
997            .find(".variation_id_selected")
998            .val(msg["key"]);
999          selected_order_bump_popup
1000            .find(".wps_ubo_price_html_for_variation")
1001            .html(msg["message"]);
1002        }
1003      },
1004    });
1005  });
1006
1007  /*==========================================================================
1008                            Variation popup add to cart
1009    ============================================================================*/
1010  /*
1011   * POP-UP ADD TO CART BUTTON [ works with variable products].
1012   * To add the selected js.
1013   */
1014  $(document).on("click", ".wps_ubo_bump_add_to_cart_button", function (e) {
1015    //This for the add to cart on the varaition popup.
1016    e.preventDefault();
1017    order_bump_index = jQuery(this).attr("offer_bump_index");
1018
1019    // Order Bump Object.
1020    var parent_wrapper_class = ".wps_bump_popup_" + order_bump_index;
1021    var popup_obj = jQuery(parent_wrapper_class);
1022
1023    // Meta form exists.
1024    if (popup_obj.length > 0) {
1025      let data_arr = [];
1026      popup_obj.find(".wps_ubo_custom_meta_field").each(function (index) {
1027        let field_obj = {};
1028        if ("" == jQuery(this).val()) {
1029          alert(jQuery(this).attr("name") + " field cannot be empty");
1030          return;
1031        } else if ("checkbox" == jQuery(this).attr("type")) {
1032          // Push the values in an array.
1033          field_obj.name = jQuery(this).attr("name");
1034          field_obj.value = jQuery(this).prop("checked");
1035          data_arr[index] = field_obj;
1036          index++;
1037        } else {
1038          // Push the values in an array.
1039          field_obj.name = jQuery(this).attr("name");
1040          field_obj.value = jQuery(this).val();
1041
1042          data_arr[index] = field_obj;
1043        }
1044      });
1045
1046      // All fields are saved!
1047      if (
1048        data_arr.length == popup_obj.find(".wps_ubo_custom_meta_field").length
1049      ) {
1050        // Close popup and send add to cart request.
1051        triggerAddOfferVariation(jQuery(this), data_arr);
1052      }
1053    } else {
1054      // Simple variable add to cart.
1055      triggerAddOfferVariation(jQuery(this), []);
1056    }
1057  });
1058
1059  /*==========================================================================
1060                                Popup closing
1061    ============================================================================*/
1062  /*
1063   * POP-UP JS.
1064   * To hide on click close.
1065   */
1066  $(document).on("click", ".wps_bump_popup_close", function (e) {
1067    order_bump_index = $(this).attr("offer_bump_index");
1068
1069    $(".wps_ubo_wrapper_index_" + order_bump_index).css(
1070      "pointer-events",
1071      "all"
1072    );
1073    $(".wps_ubo_wrapper_index_" + order_bump_index).css("opacity", "1");
1074    $("body").removeClass("wps_upsell_variation_pop_up_body");
1075    $(".wps_bump_popup_" + order_bump_index).css("display", "none");
1076    $(".wps_ubo_wrapper_index_" + order_bump_index)
1077      .find(".add_offer_in_cart")
1078      .prop("checked", false);
1079    $(".wps_bump_popup_meta_form_fields").css("display", "none");
1080  });
1081
1082  // Onclick outside the div close the popup.
1083  $("body").click(function (e) {
1084    if (e.target.className.toString().search("wps_bump_popup_wrapper") == 0) {
1085      order_bump_index = e.target.className.replace(
1086        "wps_bump_popup_wrapper wps_bump_popup_",
1087        ""
1088      );
1089
1090      $(".wps_ubo_wrapper_index_" + order_bump_index).css(
1091        "pointer-events",
1092        "all"
1093      );
1094      $(".wps_ubo_wrapper_index_" + order_bump_index).css("opacity", "1");
1095      $("body").removeClass("wps_upsell_variation_pop_up_body");
1096      $(".wps_bump_popup_wrapper").hide();
1097      $(".wps_ubo_wrapper_index_" + order_bump_index)
1098        .find(".add_offer_in_cart")
1099        .prop("checked", false);
1100    }
1101  });
1102
1103  /*==========================================================================
1104                                Zooming Effect on mobile.
1105    ============================================================================*/
1106  if (wps_ubo_lite_public.mobile_view != 1) {
1107    // Function for zooming image( not for mobile view ).
1108    $(document).on("hover", ".wps_bump_popup_image", function (e) {
1109      // Block opening image.
1110      e.preventDefault();
1111      $(".woocommerce-product-gallery__image").zoom({
1112        magnify: 1.0, // Magnify upto 120 %.
1113      });
1114    });
1115  } else {
1116    $(document).on("click", ".wps_bump_popup_image", function (e) {
1117      // Block opening image.
1118      e.preventDefault();
1119    });
1120  }
1121
1122  /*=====================================================================================
1123                                Mini Cart Update on Checkout on Adding Bump Offer.
1124    ======================================================================================*/
1125  /**
1126   * Update The Mini-Cart On Adding Bump Offer.
1127   *
1128   * @param {string} wps_current_theme    Current Theme Name.
1129   */
1130  function wps_minicart_update(wps_current_theme) {
1131    if (wps_current_theme == "Storefront") {
1132      $("#site-header-cart").load(window.location.href + " #site-header-cart"); //StoreFront.
1133    }
1134  }
1135
1136  if ("on" == wps_ubo_lite_public.wps_popup_exit_intent) {
1137    $("html").bind("mouseleave", function () {
1138      // $(".close-button").parent().show();
1139      wps_show_pop_up();
1140      $("html").unbind("mouseleave");
1141    });
1142  } else {
1143    // $(".close-button").parent().show();
1144    setTimeout(function () {
1145      wps_show_pop_up();
1146    }, wps_ubo_lite_public.wps_delay_time * 1000);
1147  }
1148
1149  function wps_show_pop_up() {
1150    // Cache popup selector (faster & cleaner)
1151    const popup = $('[popup-name="popup-1"]');
1152    const type = wps_ubo_lite_public.wps_popup_type;
1153    switch (type) {
1154      case "lightbox":
1155        popup.addClass("wps-ubo-show-popup-show wps-ubo-show-popup-lightbox");
1156        break;
1157
1158      case "slidein":
1159        popup.addClass("wps-ubo-show-popup-show wps-ubo-show-popup-down");
1160        break;
1161
1162      case "fullscreen":
1163        popup.addClass("wps-ubo-show-popup-show wps-ubo-show-popup-full");
1164        const popCont = $(".wrapup_order_bump");
1165        $(popCont).detach().insertBefore("header");
1166        break;
1167
1168      case "slideleft":
1169        popup.addClass("wps-ubo-show-popup-show wps-ubo-show-popup-left");
1170        break;
1171
1172      case "slideright":
1173        popup.addClass("wps-ubo-show-popup-show wps-ubo-show-popup-right");
1174        break;
1175
1176      case "slideup":
1177        popup.addClass("wps-ubo-show-popup-show wps-ubo-show-popup-up");
1178        break;
1179
1180      case "zoomout":
1181        popup.addClass("wps-ubo-show-popup-show wps-ubo-show-popup-zoomout");
1182        break;
1183
1184      default:
1185        popup.fadeIn(300); // fallback effect
1186        break;
1187    }
1188
1189    $(".fusion-header-wrapper").css("display", "none"); ///Avada header hidden on popup.
1190    $(".wps-popup-content-in").slick({
1191      slidesToShow: 1,
1192      slidesToScroll: 1,
1193      autoplay: false,
1194      autoplaySpeed: 1500,
1195      lazyLoad: "ondemand",
1196      fade: true,
1197      speed: 800,
1198      cssEase: "ease-in-out",
1199      prevArrow: '<span class="slide-arrow prev-arrow"></span>',
1200      nextArrow: '<span class="slide-arrow next-arrow"></span>',
1201      useTransform: true,
1202      useCSS: true,
1203      responsive: [
1204        {
1205          breakpoint: 768,
1206          settings: {
1207            arrows: false,
1208          },
1209        },
1210      ],
1211    });
1212    //Hide the header on popup open.
1213    if ("Divi" == wps_ubo_lite_public.current_theme) {
1214      $("#main-header").css("display", "none");
1215    }
1216
1217    if ("Avada" == wps_ubo_lite_public.current_theme) {
1218      $(".fusion-header-wrapper").css("display", "none");
1219    }
1220  }
1221
1222  setTimeout(function () {
1223    // Select the original wrap
1224    var wrap = $(".wrapup_order_bump").first();
1225
1226    if (!wrap.length) {
1227        console.warn("wrapup_order_bump not found");
1228        return;
1229    }
1230
1231    // Clone the wrap so we can extract clean HTML
1232    var cloned = wrap.clone();
1233
1234    // Remove unwanted section from clone
1235    cloned.find(".wps_order_bump_without_popup_wrap").remove();
1236
1237    // Get only the HTML that will be moved
1238    var data = cloned.html();
1239
1240    // Prepend the cleaned content to checkout/cart body
1241    $("body.woocommerce-checkout, body.woocommerce-cart").prepend(
1242      '<div class="wrapup_order_bump">' + data + "</div>"
1243    );
1244
1245    // NOW REMOVE only the moved parts from original
1246    wrap.find(".open-button").remove();
1247    wrap.find(".wps_uobo_product_popup").remove();
1248  }, 2000);
1249
1250  // Close Popup.
1251  $(document).on("click", ".close-button ", function (e) {
1252    $(".fusion-header-wrapper").css("display", "block"); ///Avada header hidden on popup.
1253    //Hide the header on popup open.
1254    if ("Divi" == wps_ubo_lite_public.current_theme) {
1255      $("#main-header").css("display", "none");
1256    }
1257
1258    var popup_name = $(this).attr("popup-close");
1259    $('[popup-name="' + popup_name + '"]').fadeOut(300);
1260    var body = document.body;
1261    body.classList.remove("wps_body_class_popup");
1262  });
1263
1264
1265
1266  $(document).on("click", function (e) {
1267    // Check if the click is outside the .content element
1268    if (!$(e.target).closest(".wps-popup-content").length) {
1269      $(".wrapup_order_bump .popup").css("display", "none"); // Hide modal
1270    }
1271  });
1272
1273  //Increase and descrease the quantity value on bump offer.
1274  $(document).on("click", ".wps-ubo__temp-prod-price-qty-add", function (e) {
1275    document.getElementById("inputtag").value++;
1276  });
1277  $(document).on("click", ".wps-ubo__temp-prod-price-qty-sub", function (e) {
1278    document.getElementById("inputtag").value--;
1279  });
1280});
1281
1282// Evergreen timer Start here.
1283jQuery(document).ready(function ($) {
1284  function startTimer(duration, display) {
1285    var timer = duration,
1286      minutes,
1287      seconds;
1288    setInterval(function () {
1289      hours = parseInt(timer / 3600, 10);
1290      minutes = parseInt((timer % 3600) / 60, 10);
1291      seconds = parseInt((timer % 3600) % 60, 10);
1292
1293      hours = hours < 10 ? "0" + hours : hours;
1294      minutes = minutes < 10 ? "0" + minutes : minutes;
1295      seconds = seconds < 10 ? "0" + seconds : seconds;
1296
1297      jQuery("#wps_hour_time_" + display).html(hours);
1298      jQuery("#wps_min_time_" + display).html(minutes);
1299      jQuery("#wps_sec_time_" + display).html(seconds);
1300
1301      if (--timer < 0) {
1302        $("#wps_timer" + display).css({ display: "none" });
1303        document.getElementById("expired_message" + display).innerHTML =
1304          "EXPIRED";
1305        document.getElementById("wps_checkbox_offer" + display).disabled = true;
1306        $("#wps_button_id_" + display).hide();
1307        $("#expired_message" + display)
1308          .parent()
1309          .css("pointer-events", "none");
1310      }
1311    }, 1000);
1312  }
1313
1314  setTimeout(function () {
1315    var columns = wps_ubo_lite_public.check_if_reload;
1316    var rows = wps_ubo_lite_public.evergreen_timer;
1317    var result = [];
1318    $.each(rows, function (index, value) {
1319      if (columns.indexOf(parseInt(index)) >= 0) {
1320        result[index] = value;
1321      }
1322    });
1323
1324    for (var key in result) {
1325      display = key;
1326      var Minutes = result[key]["evegreen_counter"] * 60; //minutes to seconds.
1327      startTimer(Minutes, display);
1328    }
1329  }, 1000);
1330});
1331// Evergreen timer end here.
1332
1333(function () {
1334  if (wps_ubo_lite_public.is_checkout_page) {
1335    function waitForWooBlocksReady(callback, tries = 0) {
1336      if (tries > 50) return;
1337      const wcBlocks = window?.wc?.blocksCheckout;
1338      if (wcBlocks?.ExperimentalOrderMeta && wp?.element && wp?.data) {
1339        callback(wcBlocks);
1340        return;
1341      }
1342      setTimeout(() => waitForWooBlocksReady(callback, tries + 1), 200);
1343    }
1344
1345    waitForWooBlocksReady((wcBlocks) => {
1346      const { registerPlugin } = wp.plugins;
1347      const { createElement, useEffect, useState } = wp.element;
1348      const { select, subscribe } = wp.data;
1349      const { ExperimentalOrderMeta } = wcBlocks;
1350
1351      const CouponNotice = () => {
1352        const [coupons, setCoupons] = useState([]);
1353
1354        useEffect(() => {
1355          const cart = select("wc/store/cart").getCartData();
1356          setCoupons(cart?.coupons || []);
1357
1358          let lastCouponCodes = (cart?.coupons || [])
1359            .map((c) => c.code)
1360            .join(",");
1361
1362          const unsubscribe = subscribe(() => {
1363            const updated = select("wc/store/cart").getCartData();
1364            const currentCodes = (updated?.coupons || [])
1365              .map((c) => c.code)
1366              .join(",");
1367
1368            setCoupons(updated?.coupons || []);
1369
1370            if (currentCodes !== lastCouponCodes) {
1371              lastCouponCodes = currentCodes;
1372              location.reload();
1373            }
1374          });
1375
1376          return () => unsubscribe();
1377        }, []);
1378      };
1379
1380      const render = () =>
1381        createElement(
1382          ExperimentalOrderMeta,
1383          null,
1384          createElement(CouponNotice, null)
1385        );
1386
1387      registerPlugin("my-coupon-notice", {
1388        render,
1389        scope: "woocommerce-checkout",
1390      });
1391    });
1392  }
1393})();
1394//Script end here.

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.