WC_Cart_Totals::__construct()publicWC 3.2.0

Sets up the items provided, and calculate totals.

Method of the class: WC_Cart_Totals{}

No Hooks.

Return

null. Nothing (null).

Usage

$WC_Cart_Totals = new WC_Cart_Totals();
$WC_Cart_Totals->__construct( $cart );
$cart(WC_Cart) (passed by reference — &)
Cart object to calculate totals for.
Default: null

Changelog

Since 3.2.0 Introduced.

WC_Cart_Totals::__construct() code WC 8.7.0

public function __construct( &$cart = null ) {
	if ( ! is_a( $cart, 'WC_Cart' ) ) {
		throw new Exception( 'A valid WC_Cart object is required' );
	}

	$this->cart          = $cart;
	$this->calculate_tax = wc_tax_enabled() && ! $cart->get_customer()->get_is_vat_exempt();
	$this->calculate();
}