Automattic\WooCommerce\Blocks\BlockTypes\ProductCollection
Utils::get_cart_location_context
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.
Method of the class: Utils{}
No Hooks.
Returns
array. The cart location context.
Usage
$result = Utils::get_cart_location_context();
Changelog
| Since 11.3.0 | Introduced. |
Utils::get_cart_location_context() Utils::get cart location context code WC 11.3.0
public static function get_cart_location_context() {
return array(
'type' => 'cart',
'sourceData' => array( 'productIds' => self::get_cart_product_ids() ),
);
}