Nadane
utworzone przez k.swiercz | cze 12, 2025
jQuery(document).ready(function($) {
$(".custom-tabs li").on("click", function() {
let kategoria = $(this).attr("data-category");
console.log("🔄 Zmiana kategorii na:", kategoria);
let wooProducts = $("#woo-tabs-section .woocommerce-products");
if (wooProducts.length === 0) {
console.error("❌ Nie znaleziono modułu WooCommerce!");
return;
}
wooProducts.fadeOut(200, function() {
console.log("🔄 Przeładowuję produkty AJAX-em dla kategorii:", kategoria);
$.ajax({
url: wc_add_to_cart_params.ajax_url,
type: "POST",
data: {
action: "woocommerce_get_products",
category: kategoria
},
success: function(response) {
wooProducts.html(response);
console.log("✅ Produkty zostały załadowane!");
// **🔥 NOWA METODA NA STYLE - WYMIENIAMY LINKI CSS**
$("link[href*='woocommerce/assets/css/']").remove();
let styleUrls = [
"woocommerce-layout.css",
"woocommerce-smallscreen.css",
"woocommerce.css",
"photoswipe/photoswipe.min.css",
"photoswipe/default-skin/default-skin.min.css",
"select2.css"
];
styleUrls.forEach(function(file) {
let newLink = $("", {
rel: "stylesheet",
type: "text/css",
href: "/wp-content/plugins/woocommerce/assets/css/" + file + "?reload=" + new Date().getTime()
});
$("head").append(newLink);
console.log("🔄 Dodano nowy styl:", file);
});
console.log("✅ Przeładowano style WooCommerce!");
wooProducts.fadeIn(300);
},
error: function() {
console.error("❌ Błąd ładowania produktów!");
}
});
});
});
});
