(function ($, elementor) { ("use strict"); $(document).on("click", ".quick_view", function () { var product_id = $(this).data("id"); get_product_details(product_id); }); //woocommerce gallery $(document).on("click", ".thumbnails a", function (e) { var img_url = $(this).attr("data-href"); $(".usk-modal-image-wrapper .images > a").attr("href", img_url); $(".usk-modal-image-wrapper .images > a > img").attr({ src: img_url, srcset: img_url, }); }); $(document).on( "click", ".usk-modal-page .usk-modal-product .images a", function (e) { e.preventDefault(); var img_url = $(this).attr("data-href"); var img_src = $(this).find("img").attr("srcset"); // $('.woocommerce-main-image').find('img').attr('src', img_url); // $('.woocommerce-main-image').find('img').attr('srcset', img_src); $(".woocommerce-main-image").closest("a").attr("href", img_url); $(".woocommerce-main-image").find("img").attr({ src: img_url, srcset: img_src, }); $("a.zoom").prettyPhoto({ hook: "data-rel", social_tools: false, theme: "pp_woocommerce", horizontal_padding: 20, opacity: 0.8, deeplinking: false, }); $("a[data-rel^='prettyPhoto']").prettyPhoto({ hook: "data-rel", social_tools: false, theme: "pp_woocommerce", horizontal_padding: 20, opacity: 0.8, deeplinking: false, }); } ); function get_product_details(product_id) { if (product_id !== undefined) { jQuery.ajax({ type: "POST", url: ultimate_store_kit_ajax_config.ajaxurl, data: { action: "ultimate_store_kit_wc_product_quick_view_content", product_id: product_id, }, success: function (response) { setTimeout(function () { $("#quick-view-id").html(response); }, 1000); }, }); } } $(".elementor-widget-usk-florence-grid").on( "click", ".usk-pagination a", function (b) { b.preventDefault(); const requestUrl = $(this).prop("href"); $.ajax({ url: requestUrl, success: function (d) { var data = $(d).find(".elementor-widget-usk-florence-grid"); $(".elementor-widget-usk-florence-grid").html(data); if (window.history.pushState) { window.history.pushState({}, "", requestUrl); } }, }); } ); // ======================================== // AJAX START // ======================================== $(".ajax_add_to_wishlist:not(.usk-active)").attr("href", "javascript:void(0);"); $(".ajax_add_to_wishlist").on("click", function (e) { // e.preventDefault(); var $this = $(this), $product_id = $this.data("product_id"), $redirect_url = $this.data("redirect_url"), $area_label = $this.data("aria_label"); $.ajax({ url: ultimate_store_kit_ajax_config.ajaxurl, data: { action: "usk_add_to_wishlist", product_id: $product_id, nonce: ultimate_store_kit_ajax_config.nonce, }, type: "POST", dataType: "JSON", success: function (response) { if (response.action === "added") { $this.addClass("usk-active").attr("aria-label", $area_label); $(".usk-wishlist-button") .find(".usk-wishlist-count") .html(response.count); $this.attr({ href: $redirect_url, }); } // else { // $this.removeClass("usk-active").attr("aria-label", response.message); // $this.attr({ // href: "javascript:void(0);", // }); // } }, error: function (response) { console.log(response); }, }); }); $(".ajax_remove_from_wishlist").on("click", function (e) { e.preventDefault(); var $this = $(this), $product_id = $this.data("product_id"); $.ajax({ url: ultimate_store_kit_ajax_config.ajaxurl, data: { action: "usk_remove_wishlist", product_id: $product_id, nonce: ultimate_store_kit_ajax_config.nonce, }, type: "POST", dataType: "JSON", success: function (response) { if (response.action == "removed") { $this.closest("tr").remove(); $(".usk-wishlist-button") .find(".usk-wishlist-count") .html(response.count); } }, error: function (response) { console.log(response); }, }); }); $(".ajax_add_to_compare:not(.usk-active)").attr("href", "javascript:void(0);"); $(".ajax_add_to_compare").on("click", function (e) { var $this = $(this), $product_id = $this.data("product_id"), $redirect_url = $this.data("redirect_url"), $area_label = $this.data("aria_label"); $.ajax({ url: ultimate_store_kit_ajax_config.ajaxurl, data: { action: "usk_add_to_compare_products", product_id: $product_id, nonce: ultimate_store_kit_ajax_config.nonce, }, type: "POST", dataType: "JSON", success: function (response) { if (response.action === "added") { $this.addClass("usk-active").attr("aria-label", $area_label); $(".usk-compare-button") .find(".usk-compare-count") .html(response.count); $this.attr({ href: $redirect_url, }); } // else { // $this.attr({ // href: "javascript:void(0);", // "aria-label": response.message, // }); // } }, error: function (response) { console.log(response); }, }); }); $(".ajax_add_to_cart").on("click", function (e) { e.preventDefault(); var $this = $(this); $this.attr("aria-label", "Added to cart"); }); // ======================================== // AJAX END // ======================================== $(document).ready(function () { var loader = `