1jQuery(function ($) { 2 const exchangeRates = CPP_Data.exchangeRates; 3 const productCurrency = CPP_Data.productCurrency; 4 const symbol = CPP_Data.currency_symbol; 5 const $form = $('form.variations_form'); 6 if ($form.length && CPP_Data.shop_behaviour !== 'convert_shop_default' && CPP_Data.shop_behaviour !== 'convert_customer_based' ) { 7 $form.on('wc_variation_form', function () { 8 const variations = $form.data('product_variations'); 9 const convertedPrices = []; 10 variations.forEach(function (variation) { 11 const price = parseFloat(variation.display_price ?? variation.variation_price ?? 0); 12 const varCurrency = variation.cpp_currency || productCurrency; 13 14 if (!price || !varCurrency || !exchangeRates[varCurrency]) { 15 return; 16 } 17 const converted = (price * exchangeRates[varCurrency]) / exchangeRates[productCurrency]; 18 convertedPrices.push(converted); 19 }); 20 if (!convertedPrices.length) { 21 return; 22 } 23 const min = Math.min(...convertedPrices).toFixed(2); 24 const max = Math.max(...convertedPrices).toFixed(2); 25 let newPriceRange = `${symbol}${min}`; 26 if (min !== max) { 27 newPriceRange += ` â ${symbol}${max}`; 28 } 29 const $priceContainer = $('.woocommerce-variation-price .price, .price'); 30 if ($priceContainer.length) { 31 $priceContainer.first().html(newPriceRange); 32 } 33 }); 34 } 35});
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.