Use common code and round in subtotal.
We round in `get_subtotal` because its a front-end method. If more precision is required then `get_cart_subtotal_for_order` needs to be called. Also use same `get_cart_subtotal_for_order` method here as well for consistency.
This commit is contained in:
parent
57d336433a
commit
3dc7df7af9
|
@ -437,12 +437,7 @@ abstract class WC_Abstract_Order extends WC_Abstract_Legacy_Order {
|
|||
* @return float
|
||||
*/
|
||||
public function get_subtotal() {
|
||||
$subtotal = 0;
|
||||
|
||||
foreach ( $this->get_items() as $item ) {
|
||||
$subtotal += wc_remove_number_precision( self::round_item_subtotal( wc_add_number_precision( $item->get_subtotal() ) ) );
|
||||
}
|
||||
|
||||
$subtotal = round( $this->get_cart_subtotal_for_order(), wc_get_price_decimals() );
|
||||
return apply_filters( 'woocommerce_order_get_subtotal', (float) $subtotal, $this );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue