Action
rpress_complete_fooditem_purchase
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#
| Parameter | Type | Description |
|---|---|---|
$fooditem_id | int | ID of the menu item (fooditem post). |
$payment_id | int | ID of the payment. |
$fooditem_type | string | Menu item type returned by rpress_get_fooditem_type. |
$fooditem | array | The cart item details for this line. |
$cart_index | int|string | Key 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), inrpress_complete_purchase()
See also#
Was this page helpful?
