Merge branch 'master' of github.com:woothemes/woocommerce

This commit is contained in:
Claudio Sanches 2015-02-23 15:24:40 -03:00
commit cb780bb3fd
4 changed files with 23 additions and 10 deletions

View File

@ -786,7 +786,7 @@ abstract class WC_Abstract_Order {
$fee_total += $item['line_total'];
}
$this->set_total( $cart_subtotal + $cart_subtotal_tax - $cart_total - $cart_total_tax, 'cart_discount' );
$this->set_total( $cart_subtotal - $cart_total, 'cart_discount' );
$this->set_total( $cart_subtotal_tax - $cart_total_tax, 'cart_discount_tax' );
$grand_total = round( $cart_total + $fee_total + $this->get_total_shipping() + $this->get_cart_tax() + $this->get_shipping_tax(), wc_get_price_decimals() );
@ -1267,9 +1267,9 @@ abstract class WC_Abstract_Order {
*/
public function get_total_discount( $ex_tax = true ) {
if ( $ex_tax ) {
return apply_filters( 'woocommerce_order_amount_total_discount', (double) $this->cart_discount - (double) $this->cart_discount_tax, $this );
} else {
return apply_filters( 'woocommerce_order_amount_total_discount', (double) $this->cart_discount, $this );
} else {
return apply_filters( 'woocommerce_order_amount_total_discount', (double) $this->cart_discount + (double) $this->cart_discount_tax, $this );
}
}
@ -1668,7 +1668,7 @@ abstract class WC_Abstract_Order {
if ( ! $tax_display ) {
$tax_display = $this->tax_display_cart;
}
return apply_filters( 'woocommerce_order_discount_to_display', wc_price( $this->get_total_discount( $tax_display === 'excl' ), array( 'currency' => $this->get_order_currency() ) ), $this );
return apply_filters( 'woocommerce_order_discount_to_display', wc_price( $this->get_total_discount( $tax_display === 'excl' && $this->display_totals_ex_tax ), array( 'currency' => $this->get_order_currency() ) ), $this );
}
/**

View File

@ -210,8 +210,8 @@ function wc_save_order_items( $order_id, $items ) {
$taxes['items'][] = $line_taxes;
// Total up
$subtotal += wc_format_decimal( $line_subtotal[ $item_id ] ) + array_sum( $line_subtotal_taxes );
$total += wc_format_decimal( $line_total[ $item_id ] ) + array_sum( $line_taxes );
$subtotal += wc_format_decimal( $line_subtotal[ $item_id ] );
$total += wc_format_decimal( $line_total[ $item_id ] );
$subtotal_tax += array_sum( $line_subtotal_taxes );
$total_tax += array_sum( $line_taxes );

View File

@ -1726,10 +1726,20 @@ class WC_Cart {
* @return float discount amount
*/
public function get_coupon_discount_amount( $code, $ex_tax = true ) {
$discount_amount = isset( $this->coupon_discount_amounts[ $code ] ) ? $this->coupon_discount_amounts[ $code ] : 0;
if ( $ex_tax ) {
return isset( $this->coupon_discount_amounts[ $code ] ) ? $this->coupon_discount_amounts[ $code ] - $this->get_coupon_discount_tax_amount( $code ) : 0;
if ( $this->prices_include_tax ) {
return $discount_amount - $this->get_coupon_discount_tax_amount( $code );
} else {
return isset( $this->coupon_discount_amounts[ $code ] ) ? $this->coupon_discount_amounts[ $code ] : 0;
return $discount_amount;
}
} else {
if ( $this->prices_include_tax ) {
return $discount_amount;
} else {
return $discount_amount + $this->get_coupon_discount_tax_amount( $code );
}
}
}
@ -1802,9 +1812,9 @@ class WC_Cart {
$total_discount = $discount_amount * $values['quantity'];
$total_discount_tax = 0;
if ( $this->prices_include_tax ) {
if ( $this->prices_include_tax || $this->tax_display_cart === 'incl' ) {
$tax_rates = WC_Tax::get_rates( $product->get_tax_class() );
$taxes = WC_Tax::calc_tax( $discount_amount, $tax_rates, true );
$taxes = WC_Tax::calc_tax( $discount_amount, $tax_rates, $this->prices_include_tax );
$total_discount_tax = WC_Tax::get_tax_total( $taxes ) * $values['quantity'];
}

View File

@ -138,6 +138,9 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
* Fix - Saving an order needs to save the discount amount ex. tax like the cart.
* Tweak - Show discounts inc. tax when showing order totals inc. tax.
= 2.3.5 - 20/02/2015 =
* Fix - Plain text address formatting.
* Fix - Detect shortcodes when saving URLs.