Action
rpress_pre_add_to_cart
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#
| Parameter | Type | Description |
|---|---|---|
$fooditem_id | int | Menu item (fooditem) post ID. |
$options | array | Cart 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), inRPRESS_Cart::add()
See also#
Was this page helpful?
