Skip to content
Docs
Get RestroPress

Function

Phone ordering functions

Updated
On this page

Functions for phone-first ordering: the store card, bottom sheets, the View cart bar and Required and Optional option groups.

15 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_mobile_ordering_enabled()#

Checks whether the mobile ordering layer is on.

False for stores that still use the legacy menu (the old_ui_ux setting). Filterable through rpress_mobile_ordering_enabled.

rpress_mobile_ordering_enabled()

Returns bool: True when the layer loads on the menu page.

Example

add_filter( 'rpress_mobile_ordering_enabled', '__return_false' );

Defined in includes/features/mobile-ordering/functions.php, line 20.

rpress_mobile_ordering_popup_only()#

Checks whether only the item popup part of the layer loads, for legacy menus.

True when the layer is off and old_ui_ux is set. Filterable through rpress_mobile_ordering_popup_only.

rpress_mobile_ordering_popup_only()

Returns bool: True when only the popup part loads.

Internal. Defined in includes/features/mobile-ordering/functions.php, line 39.

rpress_mobile_ordering_is_menu_page()#

Checks whether the current request shows a menu page.

True on the front end when the current post contains the fooditems shortcode or the rpress/food-menu block.

rpress_mobile_ordering_is_menu_page()

Returns bool: True on a menu page.

Internal. Defined in includes/features/mobile-ordering/functions.php, line 59.

rpress_mobile_ordering_service()#

Returns the service slug the customer is ordering for.

Uses the requested service if it is enabled, then the service context from rpress_get_service_context(), then the default enabled service, then delivery.

rpress_mobile_ordering_service( $requested = '' )

Parameters

ParameterTypeDefaultDescription
$requestedstring''Optional service slug from a request.

Returns string: A service slug such as delivery or pickup.

Example

$service = rpress_mobile_ordering_service();

Defined in includes/features/mobile-ordering/functions.php, line 78.

rpress_mobile_ordering_format_time()#

Formats a unix timestamp the way the store shows times.

Uses rpress_service_hours_time_format() when available, otherwise the WordPress time_format option, with wp_date().

rpress_mobile_ordering_format_time( $timestamp )

Parameters

ParameterTypeDefaultDescription
$timestampintRequiredUnix timestamp.

Returns string: The formatted time.

Internal. Defined in includes/features/mobile-ordering/functions.php, line 99.

rpress_mobile_ordering_next_open()#

Returns text saying when the store next takes orders for a service.

Looks up the next available slot in the slot engine and returns today at, tomorrow at, or a date and time. Returns an empty string when the engine is off or no slot is found.

rpress_mobile_ordering_next_open( $service )

Parameters

ParameterTypeDefaultDescription
$servicestringRequiredService slug.

Returns string: For example "tomorrow at 10:00", or an empty string.

Internal. Defined in includes/features/mobile-ordering/functions.php, line 112.

rpress_mobile_ordering_store_state()#

Returns the facts the store card shows for one service.

Includes whether the store is open, a status line (Open now, Open until a time, or Closed), the next opening text, whether scheduling for later is possible, and short chips for prep time, flat delivery fee and minimum order. Filterable through rpress_mobile_ordering_store_state.

rpress_mobile_ordering_store_state( $service )

Parameters

ParameterTypeDefaultDescription
$servicestringRequiredService slug.

Returns array: Array with service, open, status, next_open, can_schedule and chips.

Example

$state = rpress_mobile_ordering_store_state( 'pickup' );
if ( ! $state['open'] ) {
	$message = $state['next_open'];
}

Defined in includes/features/mobile-ordering/functions.php, line 150.

rpress_mobile_ordering_store_card_html()#

Returns the store card markup for a service.

Built from rpress_mobile_ordering_store_state(). When closed it shows the next opening time or the store closed message, and a Schedule for later button if allowed.

rpress_mobile_ordering_store_card_html( $service )

Parameters

ParameterTypeDefaultDescription
$servicestringRequiredService slug.

Returns string: HTML markup, escaped while built.

Internal. Defined in includes/features/mobile-ordering/functions.php, line 222.

rpress_mobile_ordering_render_store_card()#

Prints the store card above the menu.

Hooked to rpress_menu_page_top at priority 5. Does nothing when the layer is off, and by default only shows for the Modern template pack; filterable through rpress_mobile_ordering_show_store_card.

rpress_mobile_ordering_render_store_card()

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/mobile-ordering/functions.php, line 268.

rpress_mobile_ordering_replace_pack_header()#

Removes the Modern pack's store header so only the store card shows.

Runs on init at priority 99 and removes RPRESS_Template_Packs::render_modern_store_header from rpress_menu_page_top when the layer is on.

rpress_mobile_ordering_replace_pack_header()

Internal. Defined in includes/features/mobile-ordering/functions.php, line 296.

rpress_mobile_ordering_ajax_store()#

Handles the AJAX request that returns a fresh store card.

Public and read-only with no nonce, so a page-cached menu still works. Reads an optional service request value and replies with the card HTML.

rpress_mobile_ordering_ajax_store()

Internal. Defined in includes/features/mobile-ordering/functions.php, line 311.

rpress_mobile_ordering_enqueue()#

Enqueues the mobile ordering stylesheet and script on menu pages.

Runs on wp_enqueue_scripts at priority 40 and passes the AJAX URL, today and tomorrow labels and strings to the script as rpress_mobile_ordering. Does nothing when the layer and popup-only mode are both off, or on pages that are neither menu nor popup pages.

rpress_mobile_ordering_enqueue()

Internal. Defined in includes/features/mobile-ordering/functions.php, line 325.

rpress_mobile_ordering_body_class()#

Adds the sheet classes to the body class list from the first paint.

Adds rp-mo-sheet-cart and rp-mo-sheet-item on menu pages, rp-mo-sheet-item on popup pages and legacy popup-only pages, and rp-mo-dark-primary when the primary colour is too dark.

rpress_mobile_ordering_body_class( $classes )

Parameters

ParameterTypeDefaultDescription
$classesarrayRequiredBody classes.

Returns array: The classes.

Internal. Defined in includes/features/mobile-ordering/functions.php, line 395.

rpress_mobile_ordering_primary_is_dark()#

Checks whether the store's primary colour is too dark for the dark Modern cart bar.

Computes the contrast of the primary colour (from the primary_color setting or the template pack) against the bar colour and returns true below 3:1.

rpress_mobile_ordering_primary_is_dark()

Returns bool: True when the colour is too dark.

Internal. Defined in includes/features/mobile-ordering/functions.php, line 418.

rpress_mobile_ordering_is_popup_page()#

Checks whether a page outside the menu opens the item popup.

True on the checkout page when the checkout upsell is active, and on posts that render the block storefront.

rpress_mobile_ordering_is_popup_page()

Returns bool: True when the popup labels and phone sheet should load.

Internal. Defined in includes/features/mobile-ordering/functions.php, line 451.

Was this page helpful?