Filter
rpress_is_free_fooditem
On this page
Filters whether a menu item, or one of its price options, is free.
Runs at the end of RPRESS_Fooditem::is_free(). The result is cast to bool. For items with variable pricing and no price ID given, the item counts as free only when both its lowest and highest price are zero.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$is_free | bool | Whether the menu item is free. |
$ID | int | Menu item ID. |
$price_id | bool|int|null | Price option ID that was checked, or false when none was given. |
Return value#
bool. True if the menu item should be treated as free.
Example#
function my_is_free_fooditem( $is_free, $fooditem_id, $price_id ) {
// Treat menu item 123 as always paid.
return 123 === (int) $fooditem_id ? false : $is_free;
}
add_filter( 'rpress_is_free_fooditem', 'my_is_free_fooditem', 10, 3 );
Source#
Applied in:
includes/class-rpress-fooditem.php(line 563), inRPRESS_Fooditem::is_free()
See also#
Was this page helpful?
