1(function () { 2 'use strict'; 3 4 /** 5 * All of the code for your public-facing JavaScript source 6 * should reside in this file. 7 * 8 * Note: It has been assumed you will write jQuery code here, so the 9 * $ function reference has been prepared for usage within the scope 10 * of this function. 11 * 12 * This enables you to define handlers, for when the DOM is ready: 13 * 14 * $(function() { 15 * 16 * }); 17 * 18 * When the window is loaded: 19 * 20 * $( window ).load(function() { 21 * 22 * }); 23 * 24 * ...and/or other possibilities. 25 * 26 * Ideally, it is not considered best practise to attach more than a 27 * single DOM-ready or window-load handler for a particular page. 28 * Although scripts in the WordPress core, Plugins and Themes may be 29 * practising this, we should strive to set a better example in our own work. 30 31 */ 32 33 jQuery(document).ready(function () { 34 jQuery('body').on('change', 'input[name="payment_method"]', function () { 35 jQuery('body').trigger('update_checkout'); 36 }); 37 var static_qty = 0; 38 jQuery(document.body).on('updated_cart_totals', function () { 39 jQuery('.product-quantity').find('.quantity input[type="hidden"]').each(function () { 40 let qty_val = jQuery(this).val(); 41 let qty_span = jQuery('<span></span>').addClass('mmqw-fixed-qunatity').text(qty_val); 42 jQuery(this).after(qty_span); 43 }); 44 static_qty++; 45 }); 46 jQuery('.product-quantity').find('.quantity input[type="hidden"]').each(function () { 47 let qty_val = jQuery(this).val(); 48 let qty_span = jQuery('<span></span>').addClass('mmqw-fixed-qunatity').text(qty_val); 49 jQuery(this).after(qty_span); 50 static_qty++; 51 }); 52 if (static_qty > 0) { 53 setTimeout(function () { 54 jQuery('button[name="update_cart"]').prop('disabled', false); 55 jQuery('button[name="update_cart"]').trigger('click'); 56 }, 2000); 57 } 58 59 setTimeout(function () { 60 jQuery('.single-product .cart').find('.quantity input[type="hidden"]').each(function () { 61 let qty_val = jQuery(this).val(); 62 console.log(jQuery(this)); 63 console.log(jQuery(this).val()); 64 let text_qty = jQuery('<strong></strong>').text(mmqw_plugin_vars.one_quantity); 65 let qty_span = jQuery('<span></span>').addClass('mmqw-fixed-qunatity').append(text_qty).append(qty_val); 66 jQuery(this).after(qty_span); 67 }); 68 }, 1000); 69 70 jQuery(document).on('change', '.input-text.qty.text', function () { 71 let currentVal = jQuery(this).val(); 72 let minVal = jQuery(this).attr('min'); 73 let maxVal = jQuery(this).attr('max'); 74 75 if (parseInt(currentVal) < parseInt(minVal)) { 76 jQuery(this).val(minVal); 77 } else if (parseInt(currentVal) > parseInt(maxVal)) { 78 jQuery(this).val(maxVal); 79 } 80 }); 81 }); 82 83 jQuery(window).on('load', function () { 84 function update_quantity() { 85 // Fires whenever variation selects are changed 86 var min_qty = jQuery('.quantity .input-text.qty.text').attr('min'); 87 if ('' !== min_qty) { 88 jQuery('.quantity .input-text.qty.text').val(min_qty); 89 } 90 } 91 jQuery('.variations_form').on('woocommerce_variation_select_change', function () { 92 setTimeout(update_quantity, 200); 93 }); 94 }); 95 96})();
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.