Filter
rpress_can_purchase_fooditem
On this page
Filters whether a menu item can be purchased.
Runs in RPRESS_Fooditem::can_purchase(). The initial value is true unless the post status is not publish. The result is cast to bool. The check is used by the cart when contents are loaded and an item is added.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$can_purchase | bool | Whether the menu item can be purchased. |
$fooditem | RPRESS_Fooditem | The menu item object. |
Return value#
bool. True if the menu item can be purchased.
Example#
function my_can_purchase_fooditem( $can_purchase, $fooditem ) {
// Block ordering menu item 123 outside business hours.
if ( 123 === (int) $fooditem->ID && (int) wp_date( 'G' ) < 11 ) {
return false;
}
return $can_purchase;
}
add_filter( 'rpress_can_purchase_fooditem', 'my_can_purchase_fooditem', 10, 2 );
Source#
Applied in:
includes/class-rpress-fooditem.php(line 627), inRPRESS_Fooditem::can_purchase()
Was this page helpful?
