WC_Cart_Totals::__constructpublicWC 3.2.0

Sets up the items provided, and calculate totals.

Метод класса: WC_Cart_Totals{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WC_Cart_Totals = new WC_Cart_Totals();
$WC_Cart_Totals->__construct( $cart );
$cart(WC_Cart) (передается по ссылке — &)
Cart object to calculate totals for.
По умолчанию: null

Список изменений

С версии 3.2.0 Введена.

Код WC_Cart_Totals::__construct() WC 10.5.2

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

	// Check if customer is VAT exempt, if customer is defined.
	$customer               = $cart->get_customer();
	$is_customer_vat_exempt = $customer && $customer->get_is_vat_exempt();

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