1jQuery(document).ready(function ($) { 2 const isVariableProduct = $("form.variations_form").length > 0; 3 const $qtyInput = $(".quantity input.qty"); 4 const $addToCartBtn = $(".single_add_to_cart_button"); 5 6 if (!isVariableProduct) { 7 const $priceWrapper = $(".for-non-subscriptions .price"); 8 let extractedPrice = 0; 9 10 if ($priceWrapper.find("ins").length) { 11 extractedPrice = parseFloat( 12 $priceWrapper 13 .find("ins .woocommerce-Price-amount") 14 .text() 15 .replace(/[^0-9.]/g, "") 16 ); 17 } else { 18 extractedPrice = parseFloat( 19 $priceWrapper 20 .find(".woocommerce-Price-amount") 21 .first() 22 .text() 23 .replace(/[^0-9.]/g, "") 24 ); 25 } 26 27 if (!isNaN(extractedPrice)) { 28 $(".single_add_to_cart_button").attr( 29 "data-original-price", 30 extractedPrice.toFixed(2) 31 ); 32 const qty = parseInt($(".quantity input.qty").val()) || 1; 33 34 // Set initial button text 35 $(".single_add_to_cart_button").text( 36 "Add to Cart - $" + (extractedPrice * qty).toFixed(0) 37 ); 38 39 // Set initial cloud coins 40 $(".cloud-coins").html(Math.round(extractedPrice * qty * 10)); 41 } 42 } 43 44 function getQuantity() { 45 return parseInt($qtyInput.val()) || 1; 46 } 47 48 $(".quantity").on("click", ".plus, .minus", function () { 49 const $input = $(this).closest(".quantity").find("input.qty"); 50 let val = parseInt($input.val()) || 0; 51 let step = parseInt($input.attr("step")) || 1; 52 let min = parseInt($input.attr("min")) || 1; 53 if ($(this).hasClass("plus")) val += step; 54 else val = Math.max(min, val - step); 55 $input.val(val).trigger("change"); 56 57 const quantity = getQuantity(); 58 const originalPrice = 59 parseFloat($addToCartBtn.attr("data-original-price")) || 0; 60 if (originalPrice) { 61 setTimeout(() => { 62 $addToCartBtn.text( 63 "Add to Cart - $" + (originalPrice * quantity).toFixed(0) 64 ); 65 }, 10); 66 } 67 68 // code written to change the cloud coins value based on the regular price 69 $(".cloud-coins").html( 70 Math.round( 71 parseFloat( 72 $(".single_add_to_cart_button").attr("data-original-price") 73 ) * 74 val * 75 10 76 ) 77 ); 78 }); 79 80 setTimeout(() => { 81 // code written to change the cloud coins value based on the regular price 82 const priceCheckInterval = setInterval(() => { 83 const originalPriceAttr = $(".single_add_to_cart_button").attr( 84 "data-original-price" 85 ); 86 const originalPrice = parseFloat(originalPriceAttr); 87 88 if (!isNaN(originalPrice)) { 89 const quantity = 90 parseInt($(".e-atc-qty-button-holder .quantity input.qty").val()) || 91 0; 92 const cloudCoins = Math.round(originalPrice * quantity * 10); 93 $(".cloud-coins").html(cloudCoins); 94 95 clearInterval(priceCheckInterval); 96 } 97 }, 50); 98 }, 100); 99});
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.