Filter
rpress_variable_default_price_id
On this page
Filters the default variable price ID of a menu item.
Runs in rpress_get_default_variable_price for menu items with variable pricing. The value is the _rpress_default_price_id meta when it points to an existing price, otherwise the first price ID. Return a different price ID to preselect another variation.
Parameters#
| Parameter | Type | Description |
|---|---|---|
$default_price_id | int | Default price ID. |
$fooditem_id | int | ID of the menu item. |
Return value#
int. The default price ID.
Example#
function my_default_price_id( $default_price_id, $fooditem_id ) {
$prices = rpress_get_variable_prices( $fooditem_id );
if ( is_array( $prices ) && isset( $prices[1] ) ) {
return 1;
}
return $default_price_id;
}
add_filter( 'rpress_variable_default_price_id', 'my_default_price_id', 10, 2 );
Source#
Applied in:
includes/fooditem-functions.php(line 251), inrpress_get_default_variable_price()
See also#
Was this page helpful?
