Only print js for free shipping fields in admin

Since WC_Shipping_Method->get_option() runs $this->get_instance_form_fields it prints out the JS even when getting the option outsite admin.
This commit is contained in:
Rasmus 2016-10-21 12:38:35 +02:00 committed by GitHub
parent 500c68d729
commit 58eaa70424
1 changed files with 24 additions and 22 deletions

View File

@ -107,6 +107,7 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
* @return array * @return array
*/ */
public function get_instance_form_fields() { public function get_instance_form_fields() {
if ( is_admin() ) {
wc_enqueue_js( " wc_enqueue_js( "
jQuery( function( $ ) { jQuery( function( $ ) {
function wcFreeShippingShowHideMinAmountField( el ) { function wcFreeShippingShowHideMinAmountField( el ) {
@ -132,6 +133,7 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
} ); } );
}); });
" ); " );
}
return parent::get_instance_form_fields(); return parent::get_instance_form_fields();
} }