Restaurant_Menu implements Component

Handles the display of a restaurant menu for a given set of options.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Interfaces, Classes and Traits

Component
Represents a restaurant menu component that can be rendered.

Table of Contents

$options  : Menu_Options
$menu_id  : mixed
$products  : array<string|int, WC_Product>
$script_loader  : Frontend_Scripts
$template_loader  : Template_Loader
__construct()  : mixed
get_categories()  : array<string|int, WP_Term>
Get the categories displayed in this menu.
get_menu()  : mixed
get_products()  : array<string|int, WC_Product>
Get the list of all products displayed in this menu.
render()  : string
Renders the restaurant menu based on the supplied options.
error_message()  : mixed
format_error_message()  : string
Format an error message for the menu.
get_anchor_prefix()  : string
Get the anchor prefix for the category sections.
get_inline_styles()  : mixed
get_menu_html_id()  : string
Get the menu's ID to use in the menu HTML template.
get_products_for_section()  : array<string|int, WC_Product>
Get the products for the specified category.
load_products()  : array<string|int, WC_Product>
Load the products to use in this menu. Calls wc_get_products.
load_scripts()  : mixed

Properties

$products

private array<string|int, WC_Product> $products = null

The products displayed in this menu.

Tags

$template_loader

private Template_Loader $template_loader

The template loader.

Tags

Methods

get_categories()

Get the categories displayed in this menu.

public get_categories() : array<string|int, WP_Term>
Tags
Return values
array<string|int, WP_Term>

The array of WP_Term objects.

get_menu()

public get_menu() : mixed
Tags
deprecated
2.0

Replaced by render

Return values
mixed

get_products()

Get the list of all products displayed in this menu.

public get_products() : array<string|int, WC_Product>
Tags
Return values
array<string|int, WC_Product>

The array of WC_Product objects.

render()

Renders the restaurant menu based on the supplied options.

public render() : string
Tags
Return values
string

The HTML for the restaurant menu.

error_message()

protected error_message(mixed $message[, mixed $show_categories = false ]) : mixed
Parameters
$message : mixed
$show_categories : mixed = false
Tags
deprecated
2.0

Replaced by format_error_message

Return values
mixed

format_error_message()

Format an error message for the menu.

protected format_error_message(string $message[, string $show_categories = false ]) : string
Parameters
$message : string

The error message.

$show_categories : string = false

Whether to show the list of categories in the error message.

Tags
Return values
string

The error message

get_anchor_prefix()

Get the anchor prefix for the category sections.

private get_anchor_prefix() : string
Tags
Return values
string

The anchor prefix.

get_inline_styles()

private get_inline_styles() : mixed
Tags
Return values
mixed

get_menu_html_id()

Get the menu's ID to use in the menu HTML template.

private get_menu_html_id() : string
Tags
Return values
string

The menu's HTML ID.

get_products_for_section()

Get the products for the specified category.

private get_products_for_section(WP_Term $category) : array<string|int, WC_Product>
Parameters
$category : WP_Term

The category to retrieve the products for.

Tags
Return values
array<string|int, WC_Product>

The list of products for the section.

load_products()

Load the products to use in this menu. Calls wc_get_products.

private load_products(array<string|int, string> $categories) : array<string|int, WC_Product>
Parameters
$categories : array<string|int, string>

The list of category slugs to load the products for.

Tags
Return values
array<string|int, WC_Product>

The array of WC_Product objects.

load_scripts()

private load_scripts() : mixed
Tags
Return values
mixed

Search results