Filter
rpress_get_variable_prices
On this page
Filters the variable price options of a menu item.
Runs at the end of RPRESS_Fooditem::get_prices(). The array is read from the rpress_variable_prices meta, and only when the item has variable pricing enabled; otherwise an empty array is passed. Each row holds fields such as name and amount.
Available since RestroPress 1.0.0.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$prices | array | Variable price rows. |
$ID | int | Menu item ID. |
Return value#
array. The variable prices.
Example#
function my_variable_prices( $prices, $fooditem_id ) {
if ( ! is_array( $prices ) ) {
return $prices;
}
foreach ( $prices as $key => $price ) {
$prices[ $key ]['amount'] = (float) $price['amount'] + 0.50;
}
return $prices;
}
add_filter( 'rpress_get_variable_prices', 'my_variable_prices', 10, 2 );
Source#
Applied in:
includes/class-rpress-fooditem.php(line 272), inRPRESS_Fooditem::get_prices()
See also#
Was this page helpful?
