Skip to content
Docs
Get RestroPress

Filter

rpress_get_cart_token

Updated
On this page

Filters the saved cart token of the current visitor.

Runs in RPRESS_Cart::get_token(). The token comes from the rpress_cart_token user meta for logged-in users, or the rpress_cart_token cookie for guests, and is used to validate a saved cart restore.

Parameters#

ParameterTypeDescription
$tokenstring|falseStored cart token, or false when a guest has no cookie.
$user_idintCurrent user ID, 0 for guests.

Return value#

string|false. The cart token.

Example#

function my_cart_token( $token, $user_id ) {
	return $token;
}
add_filter( 'rpress_get_cart_token', 'my_cart_token', 10, 2 );

Source#

Applied in:

  • includes/cart/class-rpress-cart.php (line 1422), in RPRESS_Cart::get_token()

See also#

Was this page helpful?