WooCommerce::initialize_cart()publicWC 3.6.4

Initialize the customer and cart objects and setup customer saving on shutdown.

Note, wc()->customer is session based. Changes to customer data via this property are not persisted to the database automatically.

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

Хуков нет.

Возвращает

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

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

$WooCommerce = new WooCommerce();
$WooCommerce->initialize_cart();

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

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

Код WooCommerce::initialize_cart() WC 8.7.0

public function initialize_cart() {
	if ( is_null( $this->customer ) || ! $this->customer instanceof WC_Customer ) {
		$this->customer = new WC_Customer( get_current_user_id(), true );
		// Customer session should be saved during shutdown.
		add_action( 'shutdown', array( $this->customer, 'save' ), 10 );
	}
	if ( is_null( $this->cart ) || ! $this->cart instanceof WC_Cart ) {
		$this->cart = new WC_Cart();
	}
}