Fix discounts rounding issues
This commit is contained in:
parent
88e0138be4
commit
9a47146716
|
@ -909,8 +909,8 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
$item->set_amount( trim( $discount, '%' ) );
|
||||
$item->set_discount_type( 'percent' );
|
||||
$this->add_item( $item );
|
||||
} elseif ( is_numeric( $discount ) && 0 < absint( $discount ) ) {
|
||||
$item->set_amount( absint( $discount ) );
|
||||
} elseif ( is_numeric( $discount ) && 0 < floatval( $discount ) ) {
|
||||
$item->set_amount( floatval( $discount ) );
|
||||
$item->set_discount_type( 'fixed' );
|
||||
$this->add_item( $item );
|
||||
}
|
||||
|
|
|
@ -295,9 +295,9 @@ class WC_Discounts {
|
|||
if ( strstr( $raw_discount, '%' ) ) {
|
||||
$discount->set_discount_type( 'percent' );
|
||||
$discount->set_amount( trim( $raw_discount, '%' ) );
|
||||
} elseif ( is_numeric( $raw_discount ) && 0 < absint( $raw_discount ) ) {
|
||||
} elseif ( is_numeric( $raw_discount ) && 0 < floatval( $raw_discount ) ) {
|
||||
$discount->set_discount_type( 'fixed' );
|
||||
$discount->set_amount( wc_add_number_precision( absint( $raw_discount ) ) );
|
||||
$discount->set_amount( wc_add_number_precision( floatval( $raw_discount ) ) );
|
||||
}
|
||||
|
||||
if ( ! $discount->get_amount() ) {
|
||||
|
|
Loading…
Reference in New Issue