Skip to content
Docs
Get RestroPress

Filter

rpress_is_free_fooditem

Updated
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#

ParameterTypeDescription
$is_freeboolWhether the menu item is free.
$IDintMenu item ID.
$price_idbool|int|nullPrice 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), in RPRESS_Fooditem::is_free()

See also#

Was this page helpful?