Merge pull request #16831 from woocommerce/fix/16794

Move cart totals setter for 3.1 compat
This commit is contained in:
Claudio Sanches 2017-09-15 15:22:19 -07:00 committed by GitHub
commit 5627014cd9
1 changed files with 4 additions and 3 deletions

View File

@ -616,6 +616,10 @@ final class WC_Cart_Totals {
$this->set_total( 'items_total', array_sum( array_values( wp_list_pluck( $this->items, 'total' ) ) ) );
$this->set_total( 'items_total_tax', array_sum( array_values( wp_list_pluck( $this->items, 'total_tax' ) ) ) );
$this->cart->set_cart_contents_total( $this->get_total( 'items_total' ) );
$this->cart->set_cart_contents_tax( array_sum( $this->get_merged_taxes( false, 'items' ) ) );
$this->cart->set_cart_contents_taxes( $this->get_merged_taxes( false, 'items' ) );
}
/**
@ -755,9 +759,6 @@ final class WC_Cart_Totals {
$this->set_total( 'total', round( $this->get_total( 'items_total', true ) + $this->get_total( 'fees_total', true ) + $this->get_total( 'shipping_total', true ) + array_sum( $this->get_merged_taxes( true ) ) ) );
// Add totals to cart object.
$this->cart->set_cart_contents_total( $this->get_total( 'items_total' ) );
$this->cart->set_cart_contents_tax( array_sum( $this->get_merged_taxes( false, 'items' ) ) );
$this->cart->set_cart_contents_taxes( $this->get_merged_taxes( false, 'items' ) );
$this->cart->set_discount_total( $this->get_total( 'discounts_total' ) );
$this->cart->set_discount_tax( $this->get_total( 'discounts_tax_total' ) );
$this->cart->set_total_tax( array_sum( $this->get_merged_taxes( false ) ) );