PageSourceSearch

https://www.3chi.com/wp-content/cache/min/1/wp-content/plugins/3c-…wc-loop-select-variations.js?ver=1790090395

js 3chi.com collected 2026-09-25 23:50:54 UTC 3,650 bytes, 7 lines download raw bytes

1jQuery(function($){function bindVariationSelectHandlers(){$('.products, .related-products-wrapper').on('change','.svatc-variation-select select[data-attribute_name]',function(e){const el=$(e.target);const variationsWrapper=el.closest('.svatc-variations');const availableVariations=JSON.parse(variationsWrapper.attr('data-product_variations'));const productWrapper=variationsWrapper.closest('div.product');const button=productWrapper.find('a.add_to_cart_button');const prodName=el.closest('div.box-text-products').find('a.woocommerce-loop-product__link').text();let matchingVariation={};for(let i=0;i<availableVariations.length;i++){matchingVariation=availableVariations[i];for(const[attr_name,attr_value]of Object.entries(availableVariations[i].attributes)){if(attr_value!==variationsWrapper.find('[name="'+attr_name+'"]').val()){matchingVariation={}}}
2if(Object.keys(matchingVariation).length!==0){break}}
3if(Object.keys(matchingVariation).length!==0){if(matchingVariation.is_in_stock===!0){if(matchingVariation.variation_id){button.removeClass('disabled').addClass('ajax_add_to_cart');button.attr('data-product_id',matchingVariation.variation_id);const newHref='?add-to-cart='+matchingVariation.variation_id;button.attr('href',newHref);button.text('ADD TO CART');button.attr('data-prod_name',prodName);button.attr('data-product_sku',matchingVariation.sku)}
4productWrapper.find('div.out-of-stock-label').remove()}else{button.removeClass('ajax_add_to_cart').addClass('disabled');button.text('OUT OF STOCK');button.removeAttr('data-product_id');button.removeAttr('href');button.removeAttr('data-prod_name');button.removeAttr('data-product_sku');button.removeAttr('data-prod_price');if(!productWrapper.find('div.out-of-stock-label').length){const oos_overlay="<div class='out-of-stock-label'>OUT OF STOCK</div>";productWrapper.find('div.box-image').append(oos_overlay)}}
5if(matchingVariation.price_html){productWrapper.find('span.price').replaceWith(matchingVariation.price_html)}
6const prodPrice=productWrapper.find('span.price').text().substring(1);button.attr('data-prod_price',prodPrice);if(matchingVariation.image){productWrapper.find('img').attr({src:matchingVariation.image.src,srcset:matchingVariation.image.srcset,width:matchingVariation.image.src_w,height:matchingVariation.image.src_h})}}else{button.removeClass('ajax_add_to_cart').addClass('disabled');button.text('ADD TO CART');button.removeAttr('data-product_id');button.removeAttr('href');button.removeAttr('data-prod_name');button.removeAttr('data-product_sku');button.removeAttr('data-prod_price');const orig_prod_attrs=JSON.parse(variationsWrapper.attr('data-orig_prod_attrs'));productWrapper.find('img').attr({src:orig_prod_attrs.img.src,srcset:orig_prod_attrs.img.srcset});productWrapper.find('span.price').empty().append(orig_prod_attrs.price);if(orig_prod_attrs.is_in_stock){productWrapper.find('div.out-of-stock-label').remove()}}});$(document).ready(function(){$(this).find('a.disabled.add_to_cart_button').removeAttr('href')});$(document).on('flatsome-infiniteScroll-append',function(){$(this).find('a.disabled.add_to_cart_button').removeAttr('href')});$(document.body).on('wc_cart_button_updated',function(){const view_cart_link=$(this).find('a.added_to_cart.wc-forward');const atc_button=$(this).find('a.add_to_cart_button.ajax_add_to_cart');view_cart_link.css('display','none');atc_button.removeClass('added')})}
7bindVariationSelectHandlers();$(document.body).on('updated_cart_totals',function(){productDropdowns=$(this).find('div.svatc-variation-select > select');productDropdowns.each(function(){$(this).prop('selectedIndex',0).change()});bindVariationSelectHandlers()})})

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.