Automattic\WooCommerce\Blocks\BlockTypes

ProductButton::initialize_cart_state()privateWC 1.0

Initialize the cart state.

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

Хуков нет.

Возвращает

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

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

// private - только в коде основоного (родительского) класса
$result = $this->initialize_cart_state();

Код ProductButton::initialize_cart_state() WC 9.8.4

private function initialize_cart_state() {
	if ( null === self::$cart ) {
		$cart = isset( WC()->cart )
			? rest_do_request( new \WP_REST_Request( 'GET', '/wc/store/v1/cart' ) )->data
			: array();

		wp_interactivity_state(
			'woocommerce',
			array(
				'cart'     => $cart,
				'nonce'    => wp_create_nonce( 'wc_store_api' ),
				'noticeId' => '',
				'restUrl'  => get_rest_url(),
			)
		);
	}
}