Skip to content
Docs
Get RestroPress

Function

Menu items and categories functions

Updated
On this page

Functions for menu items: prices, add-ons, categories, availability and the menu items post type.

99 functions. Each entry shows the signature, parameters, return value and where it is defined. Functions marked internal are hook callbacks, screen renderers and other plumbing that extensions normally do not call.

rpress_fooditem_is_unavailable()#

Checks whether a menu item is marked as unavailable (sold out).

Reads the rp_stock_status post meta and compares it to unavailable.

rpress_fooditem_is_unavailable( $post_id )

Parameters

ParameterTypeDefaultDescription
$post_idintRequiredMenu item (post) ID.

Returns bool: True when rp_stock_status equals unavailable, false otherwise.

Example

if ( rpress_fooditem_is_unavailable( 123 ) ) {
	echo 'Sold out';
}

Defined in includes/admin/fooditems/availability.php, line 17.

rpress_render_availability_publish_row()#

Outputs the Availability toggle row in the Publish box of the menu item editor.

Hooked to post_submitbox_misc_actions. Prints nothing unless the post is a fooditem. The row contains a hidden rp_stock_status field that is saved by rpress_save_fooditem_availability().

rpress_render_availability_publish_row( $post = null )

Parameters

ParameterTypeDefaultDescription
$postWP_Post|nullnullPost object. Defaults to the current post via get_post().

Note: Echoes output instead of returning it.

Internal. Defined in includes/admin/fooditems/availability.php, line 26.

rpress_save_fooditem_availability()#

Saves the rp_stock_status value when a menu item is saved in the editor.

Hooked to save_post at priority 20. Skips autosaves and revisions, requires a valid restropress_meta_nonce for the restropress_save_data action and the edit_post capability. Stores unavailable when that value is posted, otherwise available.

rpress_save_fooditem_availability( $post_id, $post )

Parameters

ParameterTypeDefaultDescription
$post_idintRequiredPost ID.
$postWP_PostRequiredPost object.

Internal. Defined in includes/admin/fooditems/availability.php, line 58.

rpress_availability_filter_orderable()#

Makes a menu item non-orderable when it is marked unavailable.

Callback for the rpress_is_orderable filter, registered at priority 5.

rpress_availability_filter_orderable( $orderable, $fooditem_id )

Parameters

ParameterTypeDefaultDescription
$orderableboolRequiredCurrent orderable state.
$fooditem_idintRequiredMenu item ID.

Returns bool: False when the item is unavailable, otherwise the value passed in.

Internal. Defined in includes/admin/fooditems/availability.php, line 87.

rpress_availability_filter_label()#

Replaces the order button label with sold-out text when a menu item is unavailable.

Callback for the rpress_not_available filter. The text is the no_stock_text value from the rpress_settings option when it is not empty, otherwise Sold Out. The result is passed through the rpress_availability_unavailable_label filter.

rpress_availability_filter_label( $label, $item_id )

Parameters

ParameterTypeDefaultDescription
$labelstringRequiredCurrent label.
$item_idintRequiredMenu item ID.

Returns string: The original label for available items, otherwise the sold-out text.

Internal. Defined in includes/admin/fooditems/availability.php, line 101.

rpress_availability_filter_item_class()#

Appends the item-disabled CSS class to the menu item wrapper when the item is unavailable.

Callback for the rpress_fooditem_class filter.

rpress_availability_filter_item_class( $classes, $item_id )

Parameters

ParameterTypeDefaultDescription
$classesstringRequiredExisting class string.
$item_idintRequiredMenu item ID.

Returns string: The class string, with item-disabled appended for unavailable items.

Internal. Defined in includes/admin/fooditems/availability.php, line 124.

rpress_availability_emit_disabled_styles()#

Prints inline CSS for unavailable menu items and the sold-out badge on the front end.

Hooked to wp_head. Greys out .item-disabled items, hides the unavailable button and styles .rp-soldout-badge.

rpress_availability_emit_disabled_styles()

Note: Echoes output instead of returning it.

Internal. Defined in includes/admin/fooditems/availability.php, line 140.

rpress_availability_render_soldout_badge()#

Outputs a Sold out badge for the current menu item when it is unavailable.

Hooked to rpress_fooditem_after_thumbnail. Uses get_the_ID() and the rpress_availability_unavailable_label filter for the badge text.

rpress_availability_render_soldout_badge()

Note: Echoes output instead of returning it.

Internal. Defined in includes/admin/fooditems/availability.php, line 183.

rpress_availability_relocate_badge_js()#

Prints a small script that moves sold-out badges into the thumbnail holder.

Hooked to wp_footer. On DOMContentLoaded it moves each .rp-soldout-badge into its sibling .rpress-thumbnail-holder so the badge overlays the image.

rpress_availability_relocate_badge_js()

Note: Echoes output instead of returning it.

Internal. Defined in includes/admin/fooditems/availability.php, line 198.

rpress_availability_should_render_column()#

Decides whether core should add its own Availability column to the menu items list.

Returns false when the RP_Inventory class exists and both the enable_stock and enable_stock_toggle settings are enabled, so the inventory extension's column is used instead.

rpress_availability_should_render_column()

Returns bool: True when core should render the column.

Internal. Defined in includes/admin/fooditems/availability.php, line 225.

rpress_availability_add_column()#

Adds the Availability column to the menu items list table.

Filter callback for rpress_fooditem_columns. Leaves the columns unchanged when rpress_availability_should_render_column() returns false.

rpress_availability_add_column( $columns )

Parameters

ParameterTypeDefaultDescription
$columnsarrayRequiredColumn list.

Returns array: Columns including rp_availability.

Internal. Defined in includes/admin/fooditems/availability.php, line 238.

rpress_availability_render_column()#

Outputs the availability toggle in the Availability column of the menu items list.

Hooked to manage_posts_custom_column at priority 9. Acts only for the rp_availability column on fooditem posts.

rpress_availability_render_column( $column_name, $post_id )

Parameters

ParameterTypeDefaultDescription
$column_namestringRequiredColumn name.
$post_idintRequiredPost ID.

Note: Echoes output instead of returning it.

Internal. Defined in includes/admin/fooditems/availability.php, line 250.

rpress_availability_ajax_toggle()#

Handles the AJAX request that toggles a menu item's availability.

Registered on wp_ajax_rpress_toggle_availability. Checks the rp_availability_toggle nonce (field nonce), reads item_id and status (available or unavailable) from POST, requires the edit_post capability, updates rp_stock_status and sends a JSON response.

rpress_availability_ajax_toggle()

Note: Ends the request with a JSON response.

Internal. Defined in includes/admin/fooditems/availability.php, line 268.

rpress_availability_admin_inline_js()#

Prints the inline script behind the availability toggles in the editor and list table.

Hooked to admin_footer. Runs only on fooditem screens and creates the nonce used by rpress_availability_ajax_toggle().

rpress_availability_admin_inline_js()

Note: Echoes output instead of returning it.

Internal. Defined in includes/admin/fooditems/availability.php, line 290.

rpress_fooditems_contextual_help()#

Adds help tabs to the menu item editor screen.

Hooked to load-post.php and load-post-new.php. Does nothing unless the screen ID is fooditem. Fires rpress_fooditems_contextual_help with the screen object after adding the tabs.

rpress_fooditems_contextual_help()

Internal. Defined in includes/admin/fooditems/contextual-help.php, line 19.

rpress_fooditem_columns()#

Defines the columns of the menu items list table.

Filter callback for manage_edit-fooditem_columns. The incoming array is replaced with the core set (checkbox, Name, category, tags, Price, Earnings, Date) and then passed through the rpress_fooditem_columns filter, which is where extensions should add columns.

rpress_fooditem_columns( $fooditem_columns )

Parameters

ParameterTypeDefaultDescription
$fooditem_columnsarrayRequiredExisting columns (ignored; the list is rebuilt).

Returns array: Filtered column list.

Note: Add columns through the rpress_fooditem_columns filter, not by filtering manage_edit-fooditem_columns at a lower priority.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 23.

rpress_render_fooditem_columns()#

Outputs the cell content for the category, tag, price, sales and earnings columns.

Hooked to manage_posts_custom_column. Acts only for fooditem posts. The sales and earnings cells show a dash unless the user has the view_product_stats capability.

rpress_render_fooditem_columns( $column_name, $post_id )

Parameters

ParameterTypeDefaultDescription
$column_namestringRequiredColumn name.
$post_idintRequiredPost ID.

Note: Echoes output instead of returning it.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 46.

rpress_sortable_fooditem_columns()#

Marks the price, sales and earnings columns as sortable.

Filter callback for manage_edit-fooditem_sortable_columns.

rpress_sortable_fooditem_columns( $columns )

Parameters

ParameterTypeDefaultDescription
$columnsarrayRequiredSortable columns.

Returns array: Sortable columns including price, sales and earnings.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 107.

rpress_sort_fooditems()#

Translates the price, sales and earnings sort options into meta queries on the menu items list.

Filter callback for request. Sorts numerically by the rpress_price, _rpress_fooditem_sales or _rpress_fooditem_earnings meta key. Applies only to the fooditem post type.

rpress_sort_fooditems( $vars )

Parameters

ParameterTypeDefaultDescription
$varsarrayRequiredRequest query vars.

Returns array: Modified query vars.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 121.

rpress_filter_fooditems()#

Restricts the menu items list to the current user's own items when they request an author filter.

Filter callback for request. If an author request value is present and the user lacks view_shop_reports, the request is limited to the current user; asking for another author ends the request with a 403 error.

rpress_filter_fooditems( $vars )

Parameters

ParameterTypeDefaultDescription
$varsarrayRequiredRequest query vars.

Returns array: Query vars, with author forced to the current user when restricted.

Note: Calls wp_die() with a 403 response if a user without view_shop_reports requests another author's items.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 164.

rpress_fooditem_load()#

Attaches the menu item list sorting and author filters to the request filter.

Hooked to load-edit.php at priority 9999. Adds rpress_sort_fooditems() and rpress_filter_fooditems() to request.

rpress_fooditem_load()

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 191.

rpress_add_fooditem_filters()#

Outputs the category, add-on group and tag drop-downs above the menu items list.

Hooked to restrict_manage_posts at priority 100. Acts only when the current post type is fooditem and renders a select for each of food-category, addon_category and fooditem_tag that has terms. Adds a hidden author field for users without view_shop_reports, unless all_posts=1 is requested.

rpress_add_fooditem_filters()

Note: Echoes output instead of returning it.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 204.

rpress_remove_month_filter()#

Removes the month drop-down from the menu items list.

Filter callback for months_dropdown_results.

rpress_remove_month_filter( $dates )

Parameters

ParameterTypeDefaultDescription
$datesarrayRequiredMonths list.

Returns array: An empty array on the fooditem list, otherwise the original list.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 264.

rpress_price_field_quick_edit()#

Outputs the price field in the Quick Edit and Bulk Edit panels of the menu items list.

Hooked to quick_edit_custom_box and bulk_edit_custom_box. Acts only for the price column of the fooditem post type. The input name is _rpress_regprice.

rpress_price_field_quick_edit( $column_name, $post_type )

Parameters

ParameterTypeDefaultDescription
$column_namestringRequiredColumn name.
$post_typestringRequiredPost type.

Note: Echoes output instead of returning it.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 280.

rpress_price_save_quick_edit()#

Saves the price entered in Quick Edit to the rpress_price meta.

Hooked to save_post. Requires the posted post_type to be fooditem, the edit_post capability and a non-autosave request, and reads _rpress_regprice from the request.

rpress_price_save_quick_edit( $post_id )

Parameters

ParameterTypeDefaultDescription
$post_idintRequiredPost ID.

Returns int|void: The post ID when a capability or autosave check fails, otherwise nothing.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 306.

rpress_save_bulk_edit()#

Handles the AJAX request that applies a price to several menu items at once.

Registered on wp_ajax_rpress_save_bulk_edit. Verifies the rpress-bulk-edit nonce (field rpress_bulk_nonce), requires the edit_products capability and updates rpress_price on each posted ID the user can edit. A price of 0 or empty is ignored.

rpress_save_bulk_edit()

Note: Ends the request with die().

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 321.

rpress_fooditem_duplicate_row_action()#

Adds a Duplicate link to the row actions of the menu items list.

Filter callback for post_row_actions. The link carries a per-item nonce and is shown only for fooditem posts the user can edit.

rpress_fooditem_duplicate_row_action( $actions, $post )

Parameters

ParameterTypeDefaultDescription
$actionsarrayRequiredRow actions.
$postWP_PostRequiredPost object.

Returns array: Row actions, including rp-row-action-duplicate when applicable.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 346.

rpress_handle_duplicate_fooditem()#

Creates a draft copy of a menu item and redirects to its edit screen.

Registered on admin_action_rpress_duplicate_fooditem. Verifies the nonce and edit_post capability, creates a draft titled with a (Copy) suffix, copies all post meta, the featured image and all taxonomy terms, then fires rpress_duplicate_fooditem with the new and original IDs.

rpress_handle_duplicate_fooditem()

Note: Ends the request with a redirect, or wp_die() on a failed check.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 360.

add_addons_price_type_columns()#

Adds the Price/Type column to the add-on group term list.

Filter callback for manage_edit-addon_category_columns. The column title is not translated.

add_addons_price_type_columns( $columns )

Parameters

ParameterTypeDefaultDescription
$columnsarrayRequiredTerm list columns.

Returns array: Columns including price-type.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 429.

add_addons_price_type_column_content()#

Returns the Price/Type cell content for add-on group terms.

Filter callback for manage_addon_category_custom_column. For top-level groups it shows the _type term meta (default Multiple); for child add-ons it shows the _price term meta as a formatted currency amount.

add_addons_price_type_column_content( $content, $column_name, $term_id )

Parameters

ParameterTypeDefaultDescription
$contentstringRequiredCurrent column content.
$column_namestringRequiredColumn name.
$term_idintRequiredTerm ID.

Returns string: Cell content.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 434.

rpress_fooditem_list_header_buttons()#

Adds Import and Export buttons next to Add New on the menu items list.

Hooked to admin_head-edit.php. Prints a script on the fooditem list screen. Import needs the edit_products capability and Export needs export_shop_reports.

rpress_fooditem_list_header_buttons()

Note: Echoes output instead of returning it.

Internal. Defined in includes/admin/fooditems/dashboard-columns.php, line 462.

rpress_fooditem_remove_default_editor_support()#

Removes the default editor and excerpt support from the fooditem post type.

Hooked to init at priority 99. The menu item editor renders its own description and short description fields.

rpress_fooditem_remove_default_editor_support()

Internal. Defined in includes/admin/fooditems/description.php, line 22.

rpress_fooditem_remove_default_excerpt_metabox()#

Removes the default excerpt meta box from the menu item editor.

Hooked to add_meta_boxes at priority 100.

rpress_fooditem_remove_default_excerpt_metabox()

Internal. Defined in includes/admin/fooditems/description.php, line 32.

rpress_fooditem_metabox_fields()#

Returns the list of meta keys saved by the legacy menu item meta box.

Includes keys such as rpress_price, _variable_pricing and rpress_variable_prices, and adds rpress_sku when SKUs are enabled. The list passes through the rpress_metabox_fields_save filter.

rpress_fooditem_metabox_fields()

Returns array: Meta keys.

Defined in includes/admin/fooditems/metabox.php, line 19.

rpress_fooditem_meta_box_save()#

Legacy save handler that stores the menu item meta box fields.

Hooked to save_post. Runs only when its own rpress_fooditem_meta_box_nonce is present, and skips autosaves, AJAX, bulk edit and revisions. Requires the edit_product capability, applies the rpress_metabox_save_{field} filters, sets rpress_price to the lowest option for variable pricing, and fires rpress_save_fooditem.

rpress_fooditem_meta_box_save( $post_id, $post )

Parameters

ParameterTypeDefaultDescription
$post_idintRequiredPost ID.
$postWP_PostRequiredPost object.

Note: The active editor save path is RP_FoodItem_Meta_Boxes::save_meta_boxes(); this handler only acts when its nonce is posted.

Internal. Defined in includes/admin/fooditems/metabox.php, line 51.

rpress_sanitize_bundled_products_save()#

Removes the item's own ID and duplicates from the bundled products list before saving.

Filter callback for rpress_metabox_save__rpress_bundled_products. Uses the global $post to find the item being saved.

rpress_sanitize_bundled_products_save( $products = array() )

Parameters

ParameterTypeDefaultDescription
$productsarrayarray()Bundled product IDs.

Returns array: De-duplicated, re-indexed list without the current item.

Internal. Defined in includes/admin/fooditems/metabox.php, line 108.

rpress_metabox_save_check_blank_rows()#

Removes rows that have no name, amount or file from a repeater array.

Drops each row whose name, amount and file values are all empty. Core does not attach it to a hook in this file.

rpress_metabox_save_check_blank_rows( $new )

Parameters

ParameterTypeDefaultDescription
$newarrayRequiredRows from the meta box.

Returns array: Rows with blank entries removed.

Internal. Defined in includes/admin/fooditems/metabox.php, line 127.

rpress_fooditem_media_strings()#

Changes the media manager button text to Insert into menu item on fooditem screens.

Filter callback for media_view_strings. Uses the global $post and the post type labels.

rpress_fooditem_media_strings( $strings )

Parameters

ParameterTypeDefaultDescription
$stringsarrayRequiredMedia manager strings.

Returns array: Strings, with insertIntoPost changed on fooditem screens.

Internal. Defined in includes/admin/fooditems/metabox.php, line 141.

rpress_hijack_rpress_fooditem_price_table_head()#

Reorders callbacks on the price table hooks so header output runs before row inputs.

Hooked to rpress_fooditem_price_table_row at priority -1. It inspects rpress_fooditem_price_table_head and rpress_fooditem_price_table_row callbacks in $wp_filter, and re-registers them in header-first order.

rpress_hijack_rpress_fooditem_price_table_head( $arg1, $arg2, $arg3 )

Parameters

ParameterTypeDefaultDescription
$arg1mixedRequiredUnused.
$arg2mixedRequiredUnused.
$arg3mixedRequiredUnused.

Internal. Defined in includes/admin/fooditems/metabox.php, line 168.

rpress_fooditem_remove_default_taxonomy_metaboxes()#

Removes the default category, tag and dietary meta boxes from the menu item editor.

Hooked to add_meta_boxes at priority 100. Removes food-categorydiv, tagsdiv-fooditem_tag and tagsdiv-dietary, which are replaced by a combined section.

rpress_fooditem_remove_default_taxonomy_metaboxes()

Internal. Defined in includes/admin/fooditems/taxonomies.php, line 23.

rpress_fooditem_tags_select2_init()#

Prints the script that turns the tag field into a Select2 tag-creation control.

Hooked to admin_footer. Runs only on fooditem screens and targets .rp-fi-tags-select.

rpress_fooditem_tags_select2_init()

Note: Echoes output instead of returning it.

Internal. Defined in includes/admin/fooditems/taxonomies.php, line 38.

rpress_get_fooditem_by()#

Retrieves a menu item post by ID, slug, name or SKU.

Supported $field values are id, slug, name and sku (case-insensitive). Slug, name and SKU lookups match any post status. Returns the raw post object, not an RPRESS_Fooditem.

rpress_get_fooditem_by( $field = '', $value = '' )

Parameters

ParameterTypeDefaultDescription
$fieldstring''Field to search by: id, slug, name or sku.
$valuemixed''Value to look for.

Returns WP_Post|false: The post, or false when a parameter is empty, the field is unsupported or nothing matches.

Example

$item = rpress_get_fooditem_by( 'slug', 'margherita-pizza' );
if ( $item ) {
	echo esc_html( $item->post_title );
}

Defined in includes/fooditem-functions.php, line 21.

rpress_get_fooditem()#

Returns an RPRESS_Fooditem object for a menu item ID or slug.

A numeric value is treated as an ID. Any other value is treated as a post name and looked up with WP_Query.

rpress_get_fooditem( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint|string0Menu item ID or slug.

Returns RPRESS_Fooditem|null: The menu item object, or null when it cannot be found.

Example

$item = rpress_get_fooditem( 123 );
if ( $item ) {
	echo esc_html( $item->get_name() );
}

Defined in includes/fooditem-functions.php, line 74.

rpress_is_free_fooditem()#

Checks whether a menu item, or one of its price options, is free.

Delegates to RPRESS_Fooditem::is_free(), whose result passes through the rpress_is_free_fooditem filter. For variable pricing without a $price_id, the item counts as free only when the lowest and highest prices are both zero.

rpress_is_free_fooditem( $fooditem_id = 0, $price_id = false )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.
$price_idint|falsefalsePrice option ID to check.

Returns bool: True when free. False for an empty ID.

Defined in includes/fooditem-functions.php, line 105.

rpress_get_fooditem_price()#

Returns the base price of a menu item.

Reads the rpress_price meta through RPRESS_Fooditem::get_price(), filterable with rpress_get_fooditem_price. For variable-priced items this meta holds the lowest option price.

rpress_get_fooditem_price( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns float|string|false: The sanitized price (0 when none is stored), or false for an empty ID.

Example

$price = rpress_get_fooditem_price( 123 );

Defined in includes/fooditem-functions.php, line 119.

rpress_price()#

Prints or returns the formatted price of a menu item.

Falls back to the current post ID when none is given. Adjusts the price for the tax display settings (tax_rate, prices_include_tax, tax_item), then applies rpress_fooditem_price (core formats the amount and adds the currency) and rpress_fooditem_price_after_html. The markup is a span.rpress_price.

rpress_price( $fooditem_id = 0, $echo = true, $price_id = false )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.
$echobooltrueTrue to echo the markup, false to return it.
$price_idint|falsefalsePrice option ID, passed to the filters only.

Returns string|void: The price markup when $echo is false, otherwise nothing.

Example

$html = rpress_price( 123, false );
echo wp_kses_post( $html );

Note: Echoes by default.

Defined in includes/fooditem-functions.php, line 135.

rpress_get_fooditem_final_price()#

Returns a menu item price with a percentage discount code applied.

Uses the rpress_price meta, or $amount_override when given. If $user_purchase_info['discount'] is a code other than none and is not a flat discount, the discounted amount is returned; flat discounts are ignored. The result passes through the rpress_final_price filter.

rpress_get_fooditem_final_price( $fooditem_id = 0, $user_purchase_info = null, $amount_override = null )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.
$user_purchase_infoarray|nullnullPurchase info; the discount key may hold a discount code.
$amount_overridestring|float|nullnullPrice to use instead of the stored price.

Returns string|float: The final price.

Defined in includes/fooditem-functions.php, line 187.

rpress_get_variable_prices()#

Returns the variable price options of a menu item.

Reads the rpress_variable_prices meta when variable pricing is enabled. The result is filterable with rpress_get_variable_prices.

rpress_get_variable_prices( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns array|false: Price options keyed by price ID (each with name and amount), an empty array when variable pricing is off, or false for an empty ID.

Example

$prices = rpress_get_variable_prices( 123 );
if ( ! empty( $prices ) ) {
	foreach ( $prices as $price_id => $price ) {
		echo esc_html( $price['name'] );
	}
}

Defined in includes/fooditem-functions.php, line 211.

rpress_has_variable_prices()#

Checks whether variable pricing is enabled for a menu item.

Reads the _variable_pricing meta through RPRESS_Fooditem::has_variable_prices().

rpress_has_variable_prices( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns bool: True when variable pricing is enabled. False for an empty ID.

Defined in includes/fooditem-functions.php, line 225.

rpress_get_default_variable_price()#

Returns the default price option ID of a variable-priced menu item.

Uses the _rpress_default_price_id meta, falling back to the first price option when it is missing or invalid. The result passes through the rpress_variable_default_price_id filter.

rpress_get_default_variable_price( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns int|false: The default price ID, or false when the item has no variable pricing.

Defined in includes/fooditem-functions.php, line 240.

rpress_get_price_option_name()#

Returns the name of a variable price option.

The result is filterable with rpress_get_price_option_name.

rpress_get_price_option_name( $fooditem_id = 0, $price_id = 0, $payment_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.
$price_idint0Price option ID.
$payment_idint0Order ID, passed to the filter only.

Returns string: The option name, or an empty string when it does not exist.

Defined in includes/fooditem-functions.php, line 262.

rpress_get_price_option_amount()#

Returns the amount of a variable price option.

The result is sanitized and filterable with rpress_get_price_option_amount.

rpress_get_price_option_amount( $fooditem_id = 0, $price_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.
$price_idint0Price option ID.

Returns float|string: The option amount, or 0.00 when the option does not exist.

Defined in includes/fooditem-functions.php, line 280.

rpress_get_lowest_price_option()#

Returns the lowest price among a menu item's variable price options.

Falls back to the current post ID when none is given. Options with an empty amount are skipped. For items without variable pricing, returns the base price.

rpress_get_lowest_price_option( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns float|string: The lowest amount, sanitized.

Defined in includes/fooditem-functions.php, line 296.

rpress_get_lowest_price_id()#

Returns the ID of the cheapest variable price option.

Falls back to the current post ID when none is given. Options with an empty amount are skipped.

rpress_get_lowest_price_id( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns int|float|string: The price option ID. For items without variable pricing it returns the base price, not an ID.

Note: Intended for variable-priced items; for other items the return value is the price. Check rpress_has_variable_prices() first.

Defined in includes/fooditem-functions.php, line 334.

rpress_get_highest_price_option()#

Returns the highest price among a menu item's variable price options.

Falls back to the current post ID when none is given. Options with an empty amount are skipped. For items without variable pricing, returns the base price.

rpress_get_highest_price_option( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns float|string: The highest amount, sanitized.

Defined in includes/fooditem-functions.php, line 366.

rpress_price_range()#

Returns the HTML for the low to high price range of a variable-priced menu item.

Adjusts both ends for the tax display settings and formats them with the currency. A single price is shown when the low and high values are equal. The result is filterable with rpress_price_range.

rpress_price_range( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns string: HTML spans for the low price and, when different, the separator and high price.

Example

echo wp_kses_post( rpress_price_range( 123 ) );

Defined in includes/fooditem-functions.php, line 397.

rpress_single_price_option_mode()#

Returns the multi-option purchase flag of a menu item.

Reads the _rpress_price_options_mode meta through RPRESS_Fooditem::is_single_price_mode(), filterable with rpress_single_price_option_mode. Uses the current post when no ID is given.

rpress_single_price_option_mode( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns bool: The flag value. False when no menu item can be determined.

Internal. Defined in includes/fooditem-functions.php, line 445.

rpress_get_fooditem_types()#

Returns the available menu item types.

Core provides 0 (Default) and bundle (Bundle). The list is filterable with rpress_fooditem_types.

rpress_get_fooditem_types()

Returns array: Type labels keyed by type slug.

Defined in includes/fooditem-functions.php, line 462.

rpress_get_fooditem_type()#

Returns the type of a menu item.

Reads the _rpress_product_type meta, defaulting to default. Filterable with rpress_get_fooditem_type.

rpress_get_fooditem_type( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns string: The item type, for example default or bundle.

Defined in includes/fooditem-functions.php, line 476.

rpress_is_bundled_product()#

Checks whether a menu item is a bundle.

rpress_is_bundled_product( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns bool: True when the item type is bundle.

Defined in includes/fooditem-functions.php, line 487.

rpress_get_bundled_products()#

Returns the IDs of the menu items in a bundle.

When $price_id is given, only the items assigned to that price option (or to all options) are returned. Without it, all bundled items are returned. Filterable with rpress_get_bundled_products.

rpress_get_bundled_products( $fooditem_id = 0, $price_id = null )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Bundle menu item ID.
$price_idint|nullnullPrice option ID to filter by.

Returns array: Bundled menu item IDs.

Defined in includes/fooditem-functions.php, line 501.

rpress_get_fooditem_earnings_stats()#

Returns the total earnings recorded for a menu item.

Reads the _rpress_fooditem_earnings meta, never below zero. If the meta does not exist yet, it is created with the value 0.

rpress_get_fooditem_earnings_stats( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns float|string: Total earnings.

Defined in includes/fooditem-functions.php, line 516.

rpress_get_fooditem_sales_stats()#

Returns the number of sales recorded for a menu item.

Reads the _rpress_fooditem_sales meta, never below zero. If the meta does not exist yet, it is created with the value 0.

rpress_get_fooditem_sales_stats( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns int|string: Sales count.

Defined in includes/fooditem-functions.php, line 527.

rpress_record_sale_in_log()#

Writes a sale entry to the logs for a menu item.

Inserts a log of type sale with the menu item as parent and the order ID and price ID as meta, using the global $rpress_logs object.

rpress_record_sale_in_log( $fooditem_id = 0, $payment_id = null, $price_id = false, $sale_date = null )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.
$payment_idint|nullnullOrder ID.
$price_idint|falsefalsePrice option ID.
$sale_datestring|nullnullSale date; defaults to now.

Internal. Defined in includes/fooditem-functions.php, line 544.

rpress_remove_fooditem_logs_on_delete()#

Deletes the log entries of a menu item when it is permanently deleted.

Hooked to delete_post. Does nothing for other post types. Not triggered when an item is only trashed.

rpress_remove_fooditem_logs_on_delete( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Post ID.

Internal. Defined in includes/fooditem-functions.php, line 568.

rpress_increase_purchase_count()#

Increases the sales count of a menu item.

Updates _rpress_fooditem_sales and fires rpress_fooditem_increase_sales.

rpress_increase_purchase_count( $fooditem_id = 0, $quantity = 1 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.
$quantityint1Amount to add.

Returns int|false: The new sales count, or false on failure.

Example

rpress_increase_purchase_count( 123, 2 );

Defined in includes/fooditem-functions.php, line 585.

rpress_decrease_purchase_count()#

Decreases the sales count of a menu item, for example after a refund.

Acts only when the current count is above zero. Updates _rpress_fooditem_sales and fires rpress_fooditem_decrease_sales.

rpress_decrease_purchase_count( $fooditem_id = 0, $quantity = 1 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.
$quantityint1Amount to subtract.

Returns int|false: The new sales count, or false on failure or when the count was already zero.

Note: The underlying meta update rejects empty values, so a result of 0 returns false and is not stored.

Defined in includes/fooditem-functions.php, line 598.

rpress_increase_earnings()#

Increases the recorded earnings of a menu item.

Updates _rpress_fooditem_earnings, filterable with rpress_fooditem_increase_earnings_amount, and fires rpress_fooditem_increase_earnings.

rpress_increase_earnings( $fooditem_id = 0, $amount = null )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.
$amountfloat|nullnullAmount to add.

Returns float|false: The new earnings total, or false on failure.

Defined in includes/fooditem-functions.php, line 610.

rpress_decrease_earnings()#

Decreases the recorded earnings of a menu item, for example after a refund.

Acts only when current earnings are above zero. Updates _rpress_fooditem_earnings, filterable with rpress_fooditem_decrease_earnings_amount, and fires rpress_fooditem_decrease_earnings.

rpress_decrease_earnings( $fooditem_id = 0, $amount = null )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.
$amountfloat|nullnullAmount to subtract.

Returns float|false: The new earnings total, or false on failure or when earnings were already zero.

Note: The underlying meta update rejects empty values, so a result of 0 returns false and is not stored.

Defined in includes/fooditem-functions.php, line 622.

rpress_get_average_monthly_fooditem_earnings()#

Returns the average monthly earnings of a menu item.

Divides total earnings by the number of whole 30-day periods since the item's post date. Items under 30 days old return their total earnings.

rpress_get_average_monthly_fooditem_earnings( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns float: Average earnings per month, never below zero.

Defined in includes/fooditem-functions.php, line 633.

rpress_get_average_monthly_fooditem_sales()#

Returns the average monthly sales of a menu item.

Divides the sales count by the number of whole 30-day periods since the item's post date. Items under 30 days old return their total sales.

rpress_get_average_monthly_fooditem_sales( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns float|int|string: Average sales per month.

Defined in includes/fooditem-functions.php, line 650.

rpress_get_product_notes()#

Returns the notes stored for a menu item.

Reads the rpress_product_notes meta, filterable with rpress_product_notes.

rpress_get_product_notes( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns string: The notes.

Defined in includes/fooditem-functions.php, line 666.

rpress_get_fooditem_sku()#

Returns the SKU of a menu item.

Reads the rpress_sku meta, filterable with rpress_get_fooditem_sku.

rpress_get_fooditem_sku( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns string|null: The SKU, or null when none is set.

Defined in includes/fooditem-functions.php, line 680.

rpress_get_fooditem_button_behavior()#

Returns the button behaviour of a menu item.

Reads _rpress_button_behavior. Falls back to add_to_cart when it is empty or when rpress_shop_supports_buy_now() is false. Filterable with rpress_get_fooditem_button_behavior.

rpress_get_fooditem_button_behavior( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns string: The behaviour, add_to_cart or the stored value such as direct.

Defined in includes/fooditem-functions.php, line 692.

rpress_fooditem_quantities_disabled()#

Checks whether quantity selection is disabled for a menu item.

Reads _rpress_quantities_disabled, filterable with rpress_fooditem_quantity_disabled.

rpress_fooditem_quantities_disabled( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Menu item ID.

Returns bool: True when quantities are disabled.

Defined in includes/fooditem-functions.php, line 702.

rpress_get_file_fooditem_method()#

Returns the file delivery method setting.

Reads the fooditem_method setting (default direct), filterable with rpress_file_fooditem_method. This is a leftover of the file download feature set.

rpress_get_file_fooditem_method()

Returns string: The method name.

Internal. Defined in includes/fooditem-functions.php, line 712.

rpress_parse_product_dropdown_value()#

Splits a product drop-down value into a menu item ID and price ID.

Values have the form 123 or 123_2, where the second part is the price option ID.

rpress_parse_product_dropdown_value( $value )

Parameters

ParameterTypeDefaultDescription
$valuestringRequiredDrop-down value.

Returns array: Array with keys fooditem_id and price_id (false when absent). Both are returned as strings.

Example

$parts = rpress_parse_product_dropdown_value( '123_2' );
$item_id = (int) $parts['fooditem_id'];

Defined in includes/fooditem-functions.php, line 723.

rpress_get_bundle_pricing_variations()#

Returns the stored bundle price conditions of a menu item.

Reads the _rpress_bundled_products_conditions meta (as an array of values).

rpress_get_bundle_pricing_variations( $fooditem_id = 0 )

Parameters

ParameterTypeDefaultDescription
$fooditem_idint0Bundle menu item ID.

Returns array|void: The meta values, or nothing when the ID is 0.

Internal. Defined in includes/fooditem-functions.php, line 736.

rpress_get_addons()#

Returns the add-on group terms, or the add-ons inside one group.

Queries the addon_category taxonomy ordered by name, including empty terms. Pass 0 for top-level groups or a group term ID for its child add-ons. Query arguments are filterable with rpress_get_addons_args and the result with rpress_get_addons.

rpress_get_addons( $parent = 0 )

Parameters

ParameterTypeDefaultDescription
$parentint0Parent term ID.

Returns array|WP_Error: Terms from get_terms().

Example

$groups = rpress_get_addons();
foreach ( $groups as $group ) {
	$children = rpress_get_addons( $group->term_id );
}

Defined in includes/fooditem-functions.php, line 749.

rpress_get_addon_data()#

Returns a term meta value of an add-on or add-on group.

Reads the term meta with get_term_meta(); the result is filterable with rpress_addon_meta. Keys used by core include _price for an add-on and _type for a group.

rpress_get_addon_data( $term_id, $field )

Parameters

ParameterTypeDefaultDescription
$term_idintRequiredTerm ID.
$fieldstringRequiredMeta key.

Returns mixed: The meta value. Nothing is returned when the term ID is empty.

Example

$price = rpress_get_addon_data( 45, '_price' );

Defined in includes/fooditem-functions.php, line 769.

rpress_get_addon_types()#

Returns the selection types available for add-on groups.

Core provides single and multiple. The rpress_addon_types filter is applied twice.

rpress_get_addon_types()

Returns array: Type labels keyed by type slug.

Defined in includes/fooditem-functions.php, line 780.

rpress_dynamic_addon_price()#

Returns the price of an add-on for a specific menu item.

Looks in the item's _addon_items meta for a price override of the add-on within its group; if there is none, returns the add-on's own _price. For variable-priced items the override is keyed by price option name, and 0.00 is returned when that option has no entry.

rpress_dynamic_addon_price( $post_id, $child_addon, $parent_addon = null, $price_id = null )

Parameters

ParameterTypeDefaultDescription
$post_idintRequiredMenu item ID.
$child_addonintRequiredAdd-on term ID.
$parent_addonint|nullnullParent add-on group term ID; looked up from the term when null.
$price_idint|nullnullPrice option ID for variable-priced items; treated as 0 when null.

Returns string|float: The add-on price.

Example

$price = rpress_dynamic_addon_price( 123, 45 );

Defined in includes/fooditem-functions.php, line 793.

rpress_setup_rpress_post_types()#

Registers the fooditem, rpress_payment and rpress_discount post types.

Hooked to init at priority 1. Filterable with rpress_fooditem_labels, rpress_fooditem_supports, rpress_fooditem_post_type_args, rpress_payment_labels and rpress_discount_labels. The fooditem type is not public and has no rewrite rules.

rpress_setup_rpress_post_types()

Internal. Defined in includes/post-types.php, line 19.

rpress_get_default_labels()#

Returns the singular and plural labels used for menu items.

Defaults are Menu Item and Menu Items, filterable with rpress_default_fooditems_name.

rpress_get_default_labels()

Returns array: Array with singular and plural keys.

Defined in includes/post-types.php, line 127.

rpress_get_label_singular()#

Returns the singular label for menu items.

rpress_get_label_singular( $lowercase = false )

Parameters

ParameterTypeDefaultDescription
$lowercaseboolfalseReturn the label in lowercase.

Returns string: The singular label.

Defined in includes/post-types.php, line 142.

rpress_get_label_plural()#

Returns the plural label for menu items.

rpress_get_label_plural( $lowercase = false )

Parameters

ParameterTypeDefaultDescription
$lowercaseboolfalseReturn the label in lowercase.

Returns string: The plural label.

Defined in includes/post-types.php, line 152.

rpress_change_default_title()#

Changes the title placeholder to Enter menu item name here.

Filter callback for enter_title_here. In the admin it applies only on fooditem screens.

rpress_change_default_title( $title )

Parameters

ParameterTypeDefaultDescription
$titlestringRequiredCurrent placeholder.

Returns string: The placeholder.

Internal. Defined in includes/post-types.php, line 163.

rpress_setup_fooditem_taxonomies()#

Registers the food-category, addon_category, fooditem_tag and dietary taxonomies.

Hooked to init at priority 0. Arguments and labels are filterable with rpress_addon_category_args, rpress_addon_category_labels, rpress_fooditem_tag_args, rpress_fooditem_tag_labels, rpress_dietary_args and rpress_dietary_labels.

rpress_setup_fooditem_taxonomies()

Internal. Defined in includes/post-types.php, line 184.

rpress_exclude_taxonomies_from_sitemap()#

Removes the menu taxonomies from the core XML sitemap.

Filter callback for wp_sitemaps_taxonomies. Removes food-category, addon_category, fooditem_tag and dietary.

rpress_exclude_taxonomies_from_sitemap( $taxonomies )

Parameters

ParameterTypeDefaultDescription
$taxonomiesarrayRequiredTaxonomy objects keyed by name.

Returns array: The remaining taxonomies.

Internal. Defined in includes/post-types.php, line 301.

rpress_untrash_fooditem_status()#

Restores a trashed menu item to the status it had before it was trashed.

Filter callback for wp_untrash_post_status. WordPress would otherwise restore the post as a draft.

rpress_untrash_fooditem_status( $new_status, $post_id, $previous_status )

Parameters

ParameterTypeDefaultDescription
$new_statusstringRequiredStatus WordPress would restore to.
$post_idintRequiredPost ID.
$previous_statusstringRequiredStatus before trashing.

Returns string: The status to restore.

Internal. Defined in includes/post-types.php, line 319.

rpress_seed_default_dietary_terms()#

Creates the default dietary label terms once.

Hooked to init at priority 11. Guarded by the rpress_dietary_seeded option. Defaults are filterable with rpress_default_dietary_terms. Duplicate unused terms of the same name are deleted.

rpress_seed_default_dietary_terms()

Internal. Defined in includes/post-types.php, line 336.

rpress_get_taxonomy_labels()#

Returns the labels of a menu taxonomy.

Only taxonomies in the rpress_allowed_fooditem_taxonomies list (addon_category, fooditem_tag, food-category by default) are accepted. The result is filterable with rpress_get_taxonomy_labels.

rpress_get_taxonomy_labels( $taxonomy = 'addon_category' )

Parameters

ParameterTypeDefaultDescription
$taxonomystring'addon_category'Taxonomy name.

Returns array|false: Array with name, singular_name and menu_name, or false for a taxonomy that is not allowed.

Example

$labels = rpress_get_taxonomy_labels( 'food-category' );
echo esc_html( $labels['singular_name'] );

Defined in includes/post-types.php, line 384.

rpress_register_post_type_statuses()#

Registers the custom post statuses used by orders and discount codes.

Hooked to init at priority 2. Registers refunded, paid, failed, revoked, abandoned, processing, active and inactive.

rpress_register_post_type_statuses()

Internal. Defined in includes/post-types.php, line 410.

rpress_updated_messages()#

Sets the post updated messages for the menu item editor.

Filter callback for post_updated_messages.

rpress_updated_messages( $messages )

Parameters

ParameterTypeDefaultDescription
$messagesarrayRequiredMessages.

Returns array: Messages including the fooditem set.

Internal. Defined in includes/post-types.php, line 488.

rpress_bulk_updated_messages()#

Sets the bulk action messages for the menu items list.

Filter callback for bulk_post_updated_messages.

rpress_bulk_updated_messages( $bulk_messages, $bulk_counts )

Parameters

ParameterTypeDefaultDescription
$bulk_messagesarrayRequiredBulk messages.
$bulk_countsarrayRequiredBulk counts.

Returns array: Messages including the fooditem set.

Internal. Defined in includes/post-types.php, line 511.

rpress_fooditem_row_actions()#

Prepends the menu item ID to the row actions of the list table.

Filter callback for post_row_actions, registered at priority 2.

rpress_fooditem_row_actions( $actions, $post )

Parameters

ParameterTypeDefaultDescription
$actionsarrayRequiredRow actions.
$postWP_PostRequiredPost object.

Returns array: Row actions, with an id entry first for fooditem posts.

Internal. Defined in includes/post-types.php, line 532.

rpress_unset_discount_query_arg()#

Clears the discount query variable from the main front-end query.

Hooked to pre_get_posts at priority 999999. When the front page uses a static page, the query is re-parsed against that page.

rpress_unset_discount_query_arg( $query )

Parameters

ParameterTypeDefaultDescription
$queryWP_QueryRequiredThe query object.

Internal. Defined in includes/query-filters.php, line 15.

rpress_prevent_canonical_redirect()#

Stops canonical redirects on the front page when a discount code is in the URL.

Filter callback for redirect_canonical.

rpress_prevent_canonical_redirect( $redirect_url, $requested_url )

Parameters

ParameterTypeDefaultDescription
$redirect_urlstring|falseRequiredRedirect URL.
$requested_urlstringRequiredRequested URL.

Returns string|false: The requested URL when a discount parameter is present, otherwise the redirect URL.

Internal. Defined in includes/query-filters.php, line 41.

Flushes rewrite rules once when a 404 occurs under the menu item slug.

Hooked to template_redirect. Applies when the first URL segment equals RPRESS_SLUG (default fooditems). It is rate limited by the rpress_refresh_404_permalinks transient (12 hours) and redirects with rpress-flush=1.

rpress_refresh_permalinks_on_bad_404()

Note: Ends the request with a redirect when it flushes.

Internal. Defined in includes/query-filters.php, line 58.

Was this page helpful?