Skip to content
Docs
Get RestroPress

Action

rpress_after_set_cart_item_quantity

Updated
On this page

Fires after the quantity of a cart line has been updated.

Runs after the cart has been saved in RPRESS_Cart::set_item_quantity() and RPRESS_Cart::set_item_quantity_by_key(). The contents argument is the full updated cart.

Parameters#

ParameterTypeDescription
$fooditem_idintMenu item (fooditem) post ID of the updated line.
$quantityintThe new quantity.
$optionsarrayOptions passed with the update, such as instruction, addon_items and price_id.
$arg4arrayThe updated cart contents.

Example#

function my_after_set_quantity( $fooditem_id, $quantity, $options, $contents ) {
	error_log( sprintf( 'Menu item %d quantity set to %d', $fooditem_id, $quantity ) );
}
add_action( 'rpress_after_set_cart_item_quantity', 'my_after_set_quantity', 10, 4 );

Notes#

In set_item_quantity_by_key() the menu item ID is read back from the updated line.

Source#

Fired from:

  • includes/cart/class-rpress-cart.php (line 814), in RPRESS_Cart::set_item_quantity()
  • includes/cart/class-rpress-cart.php (line 852), in RPRESS_Cart::set_item_quantity_by_key()

See also#

Was this page helpful?