Skip to content
Docs
Get RestroPress

Filter

rpress_block_storefront_cart_state

Updated
On this page

Filters the cart state sent to the block storefront's Interactivity store.

Built from the live cart and used when seeding the Interactivity store and in the read-only AJAX cart response. Keys include 'items', 'count', 'hasItems', 'countLabel', 'subtotal', 'fees', 'tax', 'showTax', 'taxLabel' and 'total'. Amounts are plain-text formatted strings.

Parameters#

ParameterTypeDescription
$statearrayCart state array.

Return value#

array. Cart state array.

Example#

add_filter( 'rpress_block_storefront_cart_state', 'my_storefront_cart_state', 10, 1 );
function my_storefront_cart_state( $state ) {
	$state['myCount'] = (int) $state['count'];
	return $state;
}

Source#

Applied in:

  • includes/features/block-storefront/functions.php (line 265), in rpress_block_storefront_cart_state()
Was this page helpful?