From b2d33f00e86ec0cc4329c332b024474b29b325e5 Mon Sep 17 00:00:00 2001 From: Caleb Burks <19caleb95@gmail.com> Date: Mon, 16 May 2016 17:06:05 -0500 Subject: [PATCH] Order change/keyup price function on change then keyup for each item. OCD issues --- assets/js/admin/woocommerce_admin.js | 34 ++++++++++++++-------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/assets/js/admin/woocommerce_admin.js b/assets/js/admin/woocommerce_admin.js index 9b3b1d806d1..f55d5770a9d 100644 --- a/assets/js/admin/woocommerce_admin.js +++ b/assets/js/admin/woocommerce_admin.js @@ -73,6 +73,23 @@ jQuery( function ( $ ) { } }) + .on( 'change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function() { + var sale_price_field = $( this ), regular_price_field; + + if( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) { + regular_price_field = sale_price_field.parents( '.variable_pricing' ).find( '.wc_input_price[name^=variable_regular_price]' ); + } else { + regular_price_field = $( '#_regular_price' ); + } + + var sale_price = parseFloat( window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point ) ); + var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) ); + + if ( sale_price >= regular_price ) { + $( this ).val( '' ); + } + }) + .on( 'keyup', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function() { var sale_price_field = $( this ), regular_price_field; @@ -92,23 +109,6 @@ jQuery( function ( $ ) { } }) - .on( 'change', '#_sale_price.wc_input_price[type=text], .wc_input_price[name^=variable_sale_price]', function() { - var sale_price_field = $( this ), regular_price_field; - - if( sale_price_field.attr( 'name' ).indexOf( 'variable' ) !== -1 ) { - regular_price_field = sale_price_field.parents( '.variable_pricing' ).find( '.wc_input_price[name^=variable_regular_price]' ); - } else { - regular_price_field = $( '#_regular_price' ); - } - - var sale_price = parseFloat( window.accounting.unformat( sale_price_field.val(), woocommerce_admin.mon_decimal_point ) ); - var regular_price = parseFloat( window.accounting.unformat( regular_price_field.val(), woocommerce_admin.mon_decimal_point ) ); - - if ( sale_price >= regular_price ) { - $( this ).val( '' ); - } - }) - .on( 'change', '.wc-order-totals #refund_amount[type=text]', function() { var regex;