/* Jarlinoa — correctif prix/photo des déclinaisons (remplace la logique de custom-product.js) custom-product.js lit data-product_variations et plante (variations.find is not a function) dès qu'un produit dépasse le seuil WooCommerce de 30 déclinaisons (mode AJAX : attribut = false), ce qui bloque aussi le handler natif WooCommerce. Ici on s'appuie sur les événements WooCommerce found_variation / reset_data, qui fonctionnent en mode inline ET en mode AJAX. */ (function () { function init() { if (!window.jQuery) { return setTimeout(init, 50); } var $ = window.jQuery; $(function () { var $form = $('form.variations_form'); if (!$form.length) { return; } // 1. Retire le handler défaillant de custom-product.js (sélecteur exact utilisé par ce script) $form.off('change', 'select[name^="attribute_"]'); // 2. Cibles dans le template Elementor "single product" (partagé par tout le site) var $price = $('.elementor-element-ecc7c52 .woocommerce-Price-amount').first(); if (!$price.length) { $price = $('h2.elementor-heading-title .woocommerce-Price-amount').first(); } var $img = $('.elementor-element-98b5914 img').first(); if (!$img.length) { $img = $form.closest('.elementor-section, .e-con, .elementor-location-single').find('.elementor-widget-image img').first(); } var priceHtml0 = $price.html(); var img0 = { src: $img.attr('src'), srcset: $img.attr('srcset') || '', sizes: $img.attr('sizes') || '' }; $form.on('found_variation', function (e, variation) { if (variation && variation.price_html && $price.length) { var $tmp = $('
').html(variation.price_html); var $amount = $tmp.find('ins .woocommerce-Price-amount').first(); if (!$amount.length) { $amount = $tmp.find('.woocommerce-Price-amount').first(); } if ($amount.length) { $price.html($amount.html()); } } if (variation && variation.image && variation.image.src && $img.length) { $img.attr({ src: variation.image.src, srcset: variation.image.srcset || '', sizes: variation.image.sizes || '' }); if (variation.image.alt) { $img.attr('alt', variation.image.alt); } } }); $form.on('reset_data', function () { if ($price.length) { $price.html(priceHtml0); } if ($img.length) { $img.attr(img0); } }); }); } init(); })();