woocommerce/assets/js/admin/meta-boxes-coupon.js

36 lines
777 B
JavaScript
Raw Normal View History

2015-07-10 04:32:30 +00:00
jQuery(function( $ ) {
2014-07-08 13:14:29 +00:00
2015-07-10 04:32:30 +00:00
/**
* Coupon actions
*/
var wc_meta_boxes_coupon_actions = {
2014-07-08 13:14:29 +00:00
2015-07-10 04:32:30 +00:00
/**
* Initialize variations actions
*/
init: function() {
$( 'select#discount_type' )
.on( 'change', this.type_options )
.change();
},
2014-07-08 13:14:29 +00:00
2015-07-10 04:32:30 +00:00
/**
* Show/hide fields by coupon type options
*/
type_options: function() {
// Get value
var select_val = $( this ).val();
2014-07-08 13:14:29 +00:00
if ( select_val !== 'fixed_cart' ) {
2015-07-10 04:32:30 +00:00
$( '.limit_usage_to_x_items_field' ).show();
$( '#coupon_amount' ).removeClass( 'wc_input_price' ).addClass( 'wc_input_decimal' );
2015-07-10 04:32:30 +00:00
} else {
$( '.limit_usage_to_x_items_field' ).hide();
$( '#coupon_amount' ).removeClass( 'wc_input_decimal' ).addClass( 'wc_input_price' );
2015-07-10 04:32:30 +00:00
}
}
};
2014-07-08 13:14:29 +00:00
2015-07-10 04:32:30 +00:00
wc_meta_boxes_coupon_actions.init();
});