Fixed show/hide free amount in modals
This commit is contained in:
parent
19713f8bc7
commit
70bf9bfcd6
|
@ -109,14 +109,27 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
|
|||
public function get_instance_form_fields() {
|
||||
wc_enqueue_js( "
|
||||
jQuery( function( $ ) {
|
||||
$( '#woocommerce_free_shipping_requires' ).change( function() {
|
||||
var minAmountField = $( '#woocommerce_free_shipping_min_amount' ).closest( 'tr' );
|
||||
if ( $(this).val() === 'coupon' || $(this).val() === '' ) {
|
||||
function wcFreeShippingShowHideminAmountField( el ) {
|
||||
var form = $( el ).closest( 'form' );
|
||||
var minAmountField = $( '#woocommerce_free_shipping_min_amount', form ).closest( 'tr' );
|
||||
if ( 'coupon' === $( el ).val() || '' === $( el ).val() ) {
|
||||
minAmountField.hide();
|
||||
} else {
|
||||
minAmountField.show();
|
||||
}
|
||||
}).change();
|
||||
}
|
||||
|
||||
$( document.body ).on( 'change', '#woocommerce_free_shipping_requires', function() {
|
||||
wcFreeShippingShowHideminAmountField( this );
|
||||
});
|
||||
|
||||
// Change while load.
|
||||
$( '#woocommerce_free_shipping_requires' ).change();
|
||||
$( document.body ).on( 'wc_backbone_modal_loaded', function( evt, target ) {
|
||||
if ( 'wc-modal-shipping-method-settings' === target ) {
|
||||
wcFreeShippingShowHideminAmountField( $( '#wc-backbone-modal-dialog #woocommerce_free_shipping_requires', evt.currentTarget ) );
|
||||
}
|
||||
} );
|
||||
});
|
||||
" );
|
||||
|
||||
|
|
Loading…
Reference in New Issue