Fix discounts rounding issues

This commit is contained in:
claudiulodro 2017-08-15 14:11:25 -07:00
parent 88e0138be4
commit 9a47146716
2 changed files with 4 additions and 4 deletions

View File

@ -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 );
}

View File

@ -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() ) {