Merge pull request #26400 from woocommerce/fix/26242
Make WC_Cart::display_prices_including_tax() aware of tax display changes
This commit is contained in:
commit
7fa34c6770
|
@ -41,13 +41,6 @@ class WC_Cart extends WC_Legacy_Cart {
|
||||||
*/
|
*/
|
||||||
public $applied_coupons = array();
|
public $applied_coupons = array();
|
||||||
|
|
||||||
/**
|
|
||||||
* Are prices in the cart displayed inc or excl tax?
|
|
||||||
*
|
|
||||||
* @var string
|
|
||||||
*/
|
|
||||||
public $tax_display_cart = 'incl';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This stores the chosen shipping methods for the cart item packages.
|
* This stores the chosen shipping methods for the cart item packages.
|
||||||
*
|
*
|
||||||
|
@ -102,9 +95,8 @@ class WC_Cart extends WC_Legacy_Cart {
|
||||||
* Constructor for the cart class. Loads options and hooks in the init method.
|
* Constructor for the cart class. Loads options and hooks in the init method.
|
||||||
*/
|
*/
|
||||||
public function __construct() {
|
public function __construct() {
|
||||||
$this->session = new WC_Cart_Session( $this );
|
$this->session = new WC_Cart_Session( $this );
|
||||||
$this->fees_api = new WC_Cart_Fees( $this );
|
$this->fees_api = new WC_Cart_Fees( $this );
|
||||||
$this->tax_display_cart = $this->is_tax_displayed();
|
|
||||||
|
|
||||||
// Register hooks for the objects.
|
// Register hooks for the objects.
|
||||||
$this->session->init();
|
$this->session->init();
|
||||||
|
@ -363,7 +355,7 @@ class WC_Cart extends WC_Legacy_Cart {
|
||||||
public function display_prices_including_tax() {
|
public function display_prices_including_tax() {
|
||||||
$customer_exempt = $this->get_customer() && $this->get_customer()->get_is_vat_exempt();
|
$customer_exempt = $this->get_customer() && $this->get_customer()->get_is_vat_exempt();
|
||||||
|
|
||||||
return apply_filters( 'woocommerce_cart_' . __FUNCTION__, 'incl' === $this->tax_display_cart && ! $customer_exempt );
|
return apply_filters( 'woocommerce_cart_' . __FUNCTION__, 'incl' === $this->is_tax_displayed() && ! $customer_exempt );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -58,15 +58,50 @@ abstract class WC_Legacy_Cart {
|
||||||
* @param mixed $value Value to set.
|
* @param mixed $value Value to set.
|
||||||
*/
|
*/
|
||||||
public function __isset( $name ) {
|
public function __isset( $name ) {
|
||||||
if ( array_key_exists( $name, $this->cart_session_data ) || 'fees' === $name ) {
|
$legacy_keys = array_merge(
|
||||||
|
array(
|
||||||
|
'dp',
|
||||||
|
'prices_include_tax',
|
||||||
|
'round_at_subtotal',
|
||||||
|
'cart_contents_total',
|
||||||
|
'total',
|
||||||
|
'subtotal',
|
||||||
|
'subtotal_ex_tax',
|
||||||
|
'tax_total',
|
||||||
|
'fee_total',
|
||||||
|
'discount_cart',
|
||||||
|
'discount_cart_tax',
|
||||||
|
'shipping_total',
|
||||||
|
'shipping_tax_total',
|
||||||
|
'display_totals_ex_tax',
|
||||||
|
'display_cart_ex_tax',
|
||||||
|
'cart_contents_weight',
|
||||||
|
'cart_contents_count',
|
||||||
|
'coupons',
|
||||||
|
'taxes',
|
||||||
|
'shipping_taxes',
|
||||||
|
'coupon_discount_amounts',
|
||||||
|
'coupon_discount_tax_amounts',
|
||||||
|
'fees',
|
||||||
|
'tax',
|
||||||
|
'discount_total',
|
||||||
|
'tax_display_cart',
|
||||||
|
),
|
||||||
|
is_array( $this->cart_session_data ) ? array_keys( $this->cart_session_data ) : array()
|
||||||
|
);
|
||||||
|
|
||||||
|
if ( in_array( $name, $legacy_keys, true ) ) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Magic getters.
|
* Magic getters.
|
||||||
*
|
*
|
||||||
|
* If you add/remove cases here please update $legacy_keys in __isset accordingly.
|
||||||
|
*
|
||||||
* @param string $name Property name.
|
* @param string $name Property name.
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
|
@ -164,6 +199,10 @@ abstract class WC_Legacy_Cart {
|
||||||
wc_deprecated_argument( 'WC_Cart->discount_total', '2.3', 'After tax coupons are no longer supported. For more information see: https://woocommerce.wordpress.com/2014/12/upcoming-coupon-changes-in-woocommerce-2-3/' );
|
wc_deprecated_argument( 'WC_Cart->discount_total', '2.3', 'After tax coupons are no longer supported. For more information see: https://woocommerce.wordpress.com/2014/12/upcoming-coupon-changes-in-woocommerce-2-3/' );
|
||||||
$value = 0;
|
$value = 0;
|
||||||
break;
|
break;
|
||||||
|
case 'tax_display_cart':
|
||||||
|
wc_deprecated_argument( 'WC_Cart->tax_display_cart', '4.3', 'Use WC_Cart->is_tax_displayed() instead.' );
|
||||||
|
$value = $this->is_tax_displayed();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue