1jQuery(function($){ 2 var $form = $('.variations_form'); 3 if(!$form.length) return; 4 5 // 1) Radia -> przepisz do ukrytych selectów Woo + odpal change 6 function bindRadios(scope){ 7 $(scope).on('change', '.product-radio input[name="attribute_pa_szerokosc"]', function(){ 8 var val = $(this).val(); 9 var $select = $form.find('select[name="attribute_pa_szerokosc"]'); 10 if($select.length){ 11 $select.val(val).trigger('change'); 12 } 13 markActive(this); 14 }); 15 // Dodaj analogiczne bindy, jeÅli bÄdziesz mieÄ kolejne atrybuty (np. pa_rozmiar) 16 $(scope).on('change', '.product-radio input[name="attribute_pa_rozmiar"]', function(){ 17 var val = $(this).val(); 18 var $select = $form.find('select[name="attribute_pa_rozmiar"]'); 19 if($select.length){ 20 $select.val(val).trigger('change'); 21 } 22 markActive(this); 23 }); 24 } 25 function markActive(inputEl){ 26 var $wrap = $(inputEl).closest('.product-radio-grid, .product-radio-btn-grid'); 27 $wrap.find('.product-radio, .product-radio-btn').removeClass('active'); 28 $(inputEl).closest('.product-radio, .product-radio-btn').addClass('active'); 29 } 30 bindRadios(document); 31 32 // 2) Aktualizacja ceny po znalezieniu wariantu 33 var $priceBox = $('#dynamic-price'); 34 var resetHtml = $priceBox.data('reset-price-html'); 35 36 $form.on('found_variation', function(evt, variation){ 37 // variation.display_price_html lub price_html (w zależnoÅci od wersji) 38 var html = variation.price_html || variation.display_price_html || ''; 39 if(html){ 40 $priceBox.html(html); 41 } 42 // odblokuj przycisk 43 $form.find('.single_add_to_cart_button').prop('disabled', false).removeClass('disabled'); 44 45 // pokaż skrót atrybutów (opcjonalnie) 46 var attrs = []; 47 if(variation.attributes && variation.attributes['attribute_pa_szerokosc']){ 48 attrs.push(variation.attributes['attribute_pa_szerokosc']); 49 } 50 if(variation.attributes && variation.attributes['attribute_pa_rozmiar']){ 51 attrs.push(variation.attributes['attribute_pa_rozmiar']); 52 } 53 $('.variation-info').text(attrs.join(' / ')); 54 }); 55 56 // 3) Reset/ukrycie wariantu 57 $form.on('reset_data hide_variation', function(){ 58 if(resetHtml){ $priceBox.html(resetHtml); } 59 $form.find('.single_add_to_cart_button').prop('disabled', true).addClass('disabled'); 60 $('.variation-info').text(''); 61 }); 62 63 // 4) Start â jeÅli coÅ jest pre-checked w Twoich radiach, zsynchronizuj 64 $('.product-radio input:checked, .product-radio-btn input:checked').trigger('change'); 65});
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.