Util

Utility functions.

Tags
author

Barn2 Plugins support@barn2.com

license

GPL-3.0

copyright

Barn2 Media Ltd

Table of Contents

$default_availability_options  : mixed
$default_restaurant_info_options  : mixed
get_assets_url()  : string
Get the URL to the /assets folder, without trailing slash.
get_default_availability_options()  : Availability_Options
Get the default availability options for the restaurant.
get_default_restaurant_info_options()  : Information_Options
Get the default information options (name, address, etc) for the restaurant.
get_menu_image_size_array()  : array<string|int, mixed>
Gets the menu image size as an array, and runs the result through a filter.
get_opening_hours()  : Opening_Hours
Get the opening hours for the restaurant.
get_restaurant_closed_error_message()  : string
Get the error message displayed when the restaurant is closed. This is used, for example, of the Cart page when the customer tries to complete an order when the restaurant is closed.
get_timezone()  : DateTimeZone
Get the timezone to use for the restaurant opening hours. Returns the result of wp_timezone().
get_wc_notices()  : array<string|int, array<string|int, mixed>>
Get the WooCommerce notices for the specified notice type. Notices are returned as a flat array of strings.
is_accepting_orders()  : bool
Is the restaurant currently accepting orders? By default, the restaurant is accepting orders when it is open.
is_restaurant_open()  : bool
Is the restaurant currently open?

Properties

$default_availability_options

private static mixed $default_availability_options = null

$default_restaurant_info_options

private static mixed $default_restaurant_info_options = null

Methods

get_assets_url()

Get the URL to the /assets folder, without trailing slash.

public static get_assets_url() : string
Return values
string

The assets URL

get_default_availability_options()

Get the default availability options for the restaurant.

public static get_default_availability_options() : Availability_Options
Return values
Availability_Options

The availability options

get_default_restaurant_info_options()

Get the default information options (name, address, etc) for the restaurant.

public static get_default_restaurant_info_options() : Information_Options
Return values
Information_Options

The information options

get_menu_image_size_array()

Gets the menu image size as an array, and runs the result through a filter.

public static get_menu_image_size_array(int $image_size[, WC_Product|null $product = null ]) : array<string|int, mixed>
Parameters
$image_size : int

The image size in pixels (i.e. the width).

$product : WC_Product|null = null

The product object to pass to the filter.

Return values
array<string|int, mixed>

The image size array

get_opening_hours()

Get the opening hours for the restaurant.

public static get_opening_hours() : Opening_Hours
Return values
Opening_Hours

The opening hours object

get_restaurant_closed_error_message()

Get the error message displayed when the restaurant is closed. This is used, for example, of the Cart page when the customer tries to complete an order when the restaurant is closed.

public static get_restaurant_closed_error_message() : string
Return values
string

The closed notice

get_timezone()

Get the timezone to use for the restaurant opening hours. Returns the result of wp_timezone().

public static get_timezone() : DateTimeZone
Return values
DateTimeZone

The restaurant timezone

get_wc_notices()

Get the WooCommerce notices for the specified notice type. Notices are returned as a flat array of strings.

public static get_wc_notices(string $notice_type) : array<string|int, array<string|int, mixed>>
Parameters
$notice_type : string

The notice type, e.g. 'error'

Return values
array<string|int, array<string|int, mixed>>

The array of notices.

is_accepting_orders()

Is the restaurant currently accepting orders? By default, the restaurant is accepting orders when it is open.

public static is_accepting_orders() : bool
Tags
throws
Exception

If there's an error fetching the opening hours.

Return values
bool

true if accepting orders, false otherwise

is_restaurant_open()

Is the restaurant currently open?

public static is_restaurant_open() : bool
Tags
throws
Exception

If there's an error fetching the opening hours.

Return values
bool

true if open

Search results