Merge pull request #23137 from woocommerce/fix/23051
Change coupon amount field type based on coupon type
This commit is contained in:
commit
17da960abe
|
@ -21,6 +21,12 @@ jQuery(function( $ ) {
|
||||||
// Get value
|
// Get value
|
||||||
var select_val = $( this ).val();
|
var select_val = $( this ).val();
|
||||||
|
|
||||||
|
if ( 'percent' === select_val ) {
|
||||||
|
$( '#coupon_amount' ).removeClass( 'wc_input_price' ).addClass( 'wc_input_decimal' );
|
||||||
|
} else {
|
||||||
|
$( '#coupon_amount' ).removeClass( 'wc_input_decimal' ).addClass( 'wc_input_price' );
|
||||||
|
}
|
||||||
|
|
||||||
if ( select_val !== 'fixed_cart' ) {
|
if ( select_val !== 'fixed_cart' ) {
|
||||||
$( '.limit_usage_to_x_items_field' ).show();
|
$( '.limit_usage_to_x_items_field' ).show();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -90,7 +90,7 @@ class WC_Meta_Box_Coupon_Data {
|
||||||
'label' => __( 'Coupon amount', 'woocommerce' ),
|
'label' => __( 'Coupon amount', 'woocommerce' ),
|
||||||
'placeholder' => wc_format_localized_price( 0 ),
|
'placeholder' => wc_format_localized_price( 0 ),
|
||||||
'description' => __( 'Value of the coupon.', 'woocommerce' ),
|
'description' => __( 'Value of the coupon.', 'woocommerce' ),
|
||||||
'data_type' => 'price',
|
'data_type' => 'percent' === $coupon->get_discount_type( 'edit' ) ? 'decimal' : 'price',
|
||||||
'desc_tip' => true,
|
'desc_tip' => true,
|
||||||
'value' => $coupon->get_amount( 'edit' ),
|
'value' => $coupon->get_amount( 'edit' ),
|
||||||
)
|
)
|
||||||
|
|
|
@ -199,7 +199,7 @@ class WC_Coupon extends WC_Legacy_Coupon {
|
||||||
* @return float
|
* @return float
|
||||||
*/
|
*/
|
||||||
public function get_amount( $context = 'view' ) {
|
public function get_amount( $context = 'view' ) {
|
||||||
return (float) $this->get_prop( 'amount', $context );
|
return wc_format_decimal( $this->get_prop( 'amount', $context ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue