Skip to content
Docs
Get RestroPress

Action

rpress_complete_fooditem_purchase

Updated
On this page

Fires for each unit of each menu item when a payment is completed for the first time.

Runs in rpress_complete_purchase inside the loop over the payment's cart items, once per quantity unit, right after the sale is recorded in the log. It runs only when the payment has no completed date yet, so it does not repeat on later status changes.

Parameters#

ParameterTypeDescription
$fooditem_idintID of the menu item (fooditem post).
$payment_idintID of the payment.
$fooditem_typestringMenu item type returned by rpress_get_fooditem_type.
$fooditemarrayThe cart item details for this line.
$cart_indexint|stringKey of this item in the payment's cart details.

Example#

function my_on_item_sold( $fooditem_id, $payment_id, $fooditem_type, $fooditem, $cart_index ) {
	$count = (int) get_post_meta( $fooditem_id, '_my_units_sold', true );
	update_post_meta( $fooditem_id, '_my_units_sold', $count + 1 );
}
add_action( 'rpress_complete_fooditem_purchase', 'my_on_item_sold', 10, 5 );

Notes#

A cart line with a quantity of 3 fires this action three times.

Source#

Fired from:

  • includes/payments/actions.php (line 53), in rpress_complete_purchase()

See also#

Was this page helpful?