Made tax display in cart depend on whether customer is tax exempt.
This commit is contained in:
parent
b7cc3077ca
commit
cf3f54ec64
|
@ -104,7 +104,7 @@ class WC_Cart extends WC_Legacy_Cart {
|
|||
public function __construct() {
|
||||
$this->session = new WC_Cart_Session( $this );
|
||||
$this->fees_api = new WC_Cart_Fees( $this );
|
||||
$this->tax_display_cart = get_option( 'woocommerce_tax_display_cart' );
|
||||
$this->tax_display_cart = $this->is_tax_displayed();
|
||||
|
||||
// Register hooks for the objects.
|
||||
$this->session->init();
|
||||
|
@ -1940,4 +1940,17 @@ class WC_Cart extends WC_Legacy_Cart {
|
|||
$this->fees_api->remove_all_fees();
|
||||
do_action( 'woocommerce_cart_reset', $this, false );
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns 'incl' if tax should be included in cart, otherwise returns 'excl'.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
private function is_tax_displayed() {
|
||||
if ( $this->get_customer() && $this->get_customer()->get_is_vat_exempt() ) {
|
||||
return 'excl';
|
||||
}
|
||||
|
||||
return get_option( 'woocommerce_tax_display_cart' );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -486,8 +486,9 @@ final class WooCommerce {
|
|||
$this->session = new $session_class();
|
||||
$this->session->init();
|
||||
|
||||
$this->cart = new WC_Cart();
|
||||
$this->customer = new WC_Customer( get_current_user_id(), true );
|
||||
// Cart needs the customer info.
|
||||
$this->cart = new WC_Cart();
|
||||
|
||||
// Customer should be saved during shutdown.
|
||||
add_action( 'shutdown', array( $this->customer, 'save' ), 10 );
|
||||
|
|
Loading…
Reference in New Issue