Skip to content
Docs
Get RestroPress

Action

rpress_pre_add_to_cart

Updated
On this page

Fires before a menu item is added to the cart.

Runs in RPRESS_Cart::add() after the menu item has been confirmed to exist and be purchasable, and before the cart is modified.

Parameters#

ParameterTypeDescription
$fooditem_idintMenu item (fooditem) post ID.
$optionsarrayCart options such as price_id, quantity, instruction and addon_items.

Example#

function my_pre_add_to_cart( $fooditem_id, $options ) {
	error_log( 'Adding menu item ' . $fooditem_id . ' to the cart' );
}
add_action( 'rpress_pre_add_to_cart', 'my_pre_add_to_cart', 10, 2 );

Notes#

Not fired when the menu item does not exist or cannot be purchased.

Source#

Fired from:

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

See also#

Was this page helpful?