Skip to content
Docs
Get RestroPress

Function

Order alerts functions

Updated
On this page

Functions for the missed-order protection email.

3 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_get_order_print_status()#

Returns the recorded print status of an order as an array.

Reads the _rpress_print_status meta. An order with no valid recorded status is reported as not_attempted, with an empty time, message and source.

rpress_get_order_print_status( $order_id )

Parameters

ParameterTypeDefaultDescription
$order_idintRequiredOrder ID.

Returns array: Array with keys status (printed, failed or not_attempted), time (int Unix time, 0 when none), message (string) and source (string).

Example

$print = rpress_get_order_print_status( 123 );
if ( 'failed' === $print['status'] ) {
	error_log( 'Print failed: ' . $print['message'] );
}

Defined in includes/features/order-alerts/functions.php, line 26.

rpress_set_order_print_status()#

Records the print status of an order so the Live Orders card can show it.

Only accepts the statuses printed, failed and not_attempted. Setting not_attempted deletes the stored status and the auto-print claim, so the order can be auto-printed again. Fires the rpress_order_print_status_updated action after saving.

rpress_set_order_print_status( $order_id, $status, $message = '', $source = '' )

Parameters

ParameterTypeDefaultDescription
$order_idintRequiredOrder ID.
$statusstringRequiredOne of printed, failed or not_attempted.
$messagestring''Optional detail, such as the failure reason.
$sourcestring''Optional source label, such as board, pos or cloud. Stored as a sanitized key.

Returns bool: True when recorded; false when the ID is not an order or the status is not recognised.

Example

rpress_set_order_print_status( 123, 'printed', '', 'my_printer' );

Defined in includes/features/order-alerts/functions.php, line 55.

rpress_claim_order_auto_print()#

Claims the automatic print of an order so only the first caller prints it.

Returns true only if the order has no recorded print status and no earlier claim exists. This stops two open Live Orders screens from both auto-printing the same order. Manual prints and retries do not need a claim.

rpress_claim_order_auto_print( $order_id )

Parameters

ParameterTypeDefaultDescription
$order_idintRequiredOrder ID.

Returns bool: True when this call obtained the claim; false for a non-order, an order already printed or failed, or an already claimed order.

Example

if ( rpress_claim_order_auto_print( 123 ) ) {
	// Send the order to the printer, then record the result.
	rpress_set_order_print_status( 123, 'printed', '', 'my_printer' );
}

Note: The claim is a unique post meta insert, which is close to atomic but not a true lock.

Defined in includes/features/order-alerts/functions.php, line 106.

Was this page helpful?