\Barn2\Plugin\WC_Restaurant_Ordering\MenuProduct_Data

Functions for retrieving data for a product in the restaurant menu.

Summary

Methods
Properties
Constants
get_display_price()
get_image_url()
get_order_type()
get_quantity_args()
No public properties found
No constants found
No protected methods found
No protected properties found
N/A
No private methods found
No private properties found
N/A

Methods

get_display_price()

get_display_price(\WC_Product  $product, boolean|string  $show_range = true, boolean  $show_sale_price = true) : string

Get the display price for a product. Similar to WC_Product->get_price_html() but without any price suffix.

Parameters

\WC_Product $product

The product object.

boolean|string $show_range

Applies to variable products only. Whether to show the range of prices (e.g. £2.00 - £4.00). true - show full price range for variable products; false - show minimum price only; 'short' - show minimum price appended with "+".

boolean $show_sale_price

Applies if product is on sale. true - show the regular price struck out before the sale price; false - just show the sale price.

Returns

string —

The display price.

get_image_url()

get_image_url(\WC_Product  $product, string  $image_size = 'woocommerce_single') : string

Get the image URL for a product. Similar to WC_Product->get_image() but returns the URL rather than the full <img> tag

.

Parameters

\WC_Product $product

The product object.

string $image_size

The image size to retrieve.

Returns

string —

The image URL, or an empty string if product has no image.

get_order_type()

get_order_type(\WC_Product  $product) : string

Get the supported order type for a product. Products with product addons and variable products always return 'lightbox'.

Parameters

\WC_Product $product

The product object.

Returns

string —

The supported order type ('lightbox' or 'quick').

get_quantity_args()

get_quantity_args(\WC_Product  $product) : array

Get the quantity args used to build to quantity input in the cart form.

Runs the result through the WC 'woocommerce_quantity_input_args' filter as plugins will override these values.

Parameters

\WC_Product $product

The product object

Returns

array —

The quantity args (input_value, min_value, max_value and step)