Skip to content
Docs
Get RestroPress

Filter

rpress_checkout_upsell_items

Updated
On this page

Filters the menu item IDs offered in the checkout upsell row.

Runs after core builds the list from the chosen source, removes items already in the cart and items that cannot be offered, and caps it at 4. The returned IDs are cast to integers, de-duplicated and cut to the same maximum of 4 again, so extra IDs are dropped.

Parameters#

ParameterTypeDescription
$idsint[]Menu item (fooditem) IDs to offer.
$settingsarrayNormalised upsell settings.
$cart_idsint[]Menu item IDs currently in the cart.

Return value#

int[]. Menu item IDs to offer.

Example#

add_filter( 'rpress_checkout_upsell_items', 'my_upsell_items', 10, 3 );
function my_upsell_items( $ids, $settings, $cart_ids ) {
	$drink = 123;
	if ( ! in_array( $drink, $cart_ids, true ) && 'publish' === get_post_status( $drink ) ) {
		array_unshift( $ids, $drink );
	}
	return $ids;
}

Source#

Applied in:

  • includes/features/checkout-upsell/loader.php (line 224), in rpress_checkout_upsell_candidate_ids()

See also#

Was this page helpful?