Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection

Utils::get_cart_location_context │ public static │ WC 11.3.0

Get a cart location context built from the current cart contents.

Used when an ancestor block provides a cart product reference for a Product Collection (e.g. the Mini-Cart overlay), independently of the page the block is rendered on.

When the cart is unavailable this still returns a cart location, with an empty product list.

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

Хуков нет.

Возвращает

array. The cart location context.

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

$result = Utils::get_cart_location_context();

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

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

Код Utils::get_cart_location_context() WC 11.3.0

public static function get_cart_location_context() {
	return array(
		'type'       => 'cart',
		'sourceData' => array( 'productIds' => self::get_cart_product_ids() ),
	);
}