Hide min order amount field when not needed

Closes #10129
This commit is contained in:
Mike Jolley 2016-02-08 11:44:08 +00:00
parent efd0304bb0
commit a35c7d6aca
1 changed files with 13 additions and 1 deletions

View File

@ -107,7 +107,7 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
'options' => array(
'' => __( 'N/A', 'woocommerce' ),
'coupon' => __( 'A valid free shipping coupon', 'woocommerce' ),
'min_amount' => __( 'A minimum order amount (defined below)', 'woocommerce' ),
'min_amount' => __( 'A minimum order amount', 'woocommerce' ),
'either' => __( 'A minimum order amount OR a coupon', 'woocommerce' ),
'both' => __( 'A minimum order amount AND a coupon', 'woocommerce' ),
)
@ -121,6 +121,18 @@ class WC_Shipping_Free_Shipping extends WC_Shipping_Method {
'desc_tip' => true
)
);
wc_enqueue_js( "
jQuery( function( $ ) {
$('#woocommerce_free_shipping_requires').change(function(){
if ( $(this).val() === 'coupon' || $(this).val() === '' ) {
$('#woocommerce_free_shipping_min_amount').closest('tr').hide();
} else {
$('#woocommerce_free_shipping_min_amount').closest('tr').show();
}
}).change();
});
" );
}
/**