From a6a26633a4ee827d759710480d154f18decc8948 Mon Sep 17 00:00:00 2001 From: Peter Fabian Date: Thu, 20 Jun 2019 14:07:52 +0200 Subject: [PATCH] Removed extra check if the code is executed within admin. --- .../class-wc-shipping-free-shipping.php | 46 +++++++++---------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/includes/shipping/free-shipping/class-wc-shipping-free-shipping.php b/includes/shipping/free-shipping/class-wc-shipping-free-shipping.php index 7efeec7773c..283c66e4b95 100644 --- a/includes/shipping/free-shipping/class-wc-shipping-free-shipping.php +++ b/includes/shipping/free-shipping/class-wc-shipping-free-shipping.php @@ -198,32 +198,30 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method { * Static so that's enqueued only once. */ public static function enqueue_admin_js() { - if ( is_admin() ) { - wc_enqueue_js( - "jQuery( function( $ ) { - 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(); - } + wc_enqueue_js( + "jQuery( function( $ ) { + 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(); } + } - $( document.body ).on( 'change', '#woocommerce_free_shipping_requires', function() { - wcFreeShippingShowHideMinAmountField( this ); - }); + $( 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 ) ); - } - } ); - });" - ); - } + // 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 ) ); + } + } ); + });" + ); } }