Skip to content
Docs
Get RestroPress

Function

Reminder emails functions

Updated
On this page

Functions that schedule and send the reminder email for scheduled orders.

22 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_reminder_register_email()#

Adds the Order Reminder email to the list of order notification emails.

Filter callback on rpress_order_notification_extra_emails. Adds an entry keyed by RPRESS_REMINDER_OPTION with the label, current enabled state and default subject, heading and content.

rpress_reminder_register_email( $emails )

Parameters

ParameterTypeDefaultDescription
$emailsarrayRequiredExtra order notification emails registered so far.

Returns array: The emails array with the reminder entry added.

Internal. Defined in includes/features/reminder-emails/admin.php, line 20.

rpress_reminder_manage_fields()#

Outputs the lead time field and tag help on the reminder email's Manage screen.

Action callback on rpress_order_notification_manage_fields. Does nothing for other emails. Echoes a table row with the minutes input, which posts as rpress_settings[order_reminder][minutes_before].

rpress_reminder_manage_fields( $email_key )

Parameters

ParameterTypeDefaultDescription
$email_keystringRequiredKey of the email being managed.

Note: Echoes output instead of returning it.

Internal. Defined in includes/features/reminder-emails/admin.php, line 42.

rpress_reminder_sanitize_settings()#

Sanitizes the reminder settings when the Emails tab is saved.

Filter callback on rpress_settings_emails_sanitize. Clamps the lead time, sanitizes subject and heading as text and content with wp_kses_post, and stores the enable flag as 'yes' when posted. Returns the input unchanged when the reminder fields are not present.

rpress_reminder_sanitize_settings( $input )

Parameters

ParameterTypeDefaultDescription
$inputarrayRequiredPosted settings.

Returns array: The settings array with the order_reminder entry sanitized.

Internal. Defined in includes/features/reminder-emails/admin.php, line 75.

rpress_reminder_default_copy()#

Returns the default subject, heading and content of the reminder email.

The subject is {reminder_message}. The content greets the customer by {name}, includes the reminder message and {fooditem_list}, and thanks them for ordering from {sitename}.

rpress_reminder_default_copy()

Returns array: Array with keys subject, heading and content.

Defined in includes/features/reminder-emails/functions.php, line 26.

rpress_reminder_default_enabled()#

Checks whether the reminder is on before the owner has saved its settings.

On for new installs, off for stores that already had an upgrade record or orders when the feature first loaded, so an update never starts emailing customers unannounced. The decision is stored once in the rpress_reminder_default option. The result passes through the rpress_reminder_default_enabled filter.

rpress_reminder_default_enabled()

Returns bool: True when the reminder is enabled by default.

Internal. Defined in includes/features/reminder-emails/functions.php, line 46.

rpress_reminder_settings()#

Returns the reminder settings with defaults applied.

Reads the order_reminder option. If the owner has saved it, the enable flag comes from the saved value; otherwise rpress_reminder_default_enabled() decides. Empty subject, heading or content fall back to the defaults. The result passes through the rpress_reminder_settings filter.

rpress_reminder_settings()

Returns array: Array with keys enabled (bool), minutes (int), subject, heading and content.

Example

$settings = rpress_reminder_settings();
if ( $settings['enabled'] ) {
	echo (int) $settings['minutes'];
}

Defined in includes/features/reminder-emails/functions.php, line 74.

rpress_reminder_clamp_minutes()#

Limits a lead time to between 5 minutes and one day.

rpress_reminder_clamp_minutes( $minutes )

Parameters

ParameterTypeDefaultDescription
$minutesmixedRequiredRaw value.

Returns int: Minutes, converted with absint and kept between 5 and 1440.

Internal. Defined in includes/features/reminder-emails/functions.php, line 93.

rpress_reminder_now()#

Returns the current Unix time used by the reminder code.

Filterable through rpress_reminder_current_time so tests can move the clock.

rpress_reminder_now()

Returns int: Unix timestamp.

Internal. Defined in includes/features/reminder-emails/functions.php, line 102.

rpress_reminder_service_timestamp()#

Returns the scheduled pickup or delivery time of an order as a Unix timestamp.

Combines the _rpress_delivery_date and _rpress_delivery_time order meta. A time stored as a range uses its start. Returns false when either value is empty, the time contains asap, or the time has no digit.

rpress_reminder_service_timestamp( $payment_id )

Parameters

ParameterTypeDefaultDescription
$payment_idintRequiredOrder ID.

Returns int|false: Unix timestamp in the site timezone, or false for ASAP orders and orders without a usable date and time.

Example

$service_at = rpress_reminder_service_timestamp( 123 );
if ( false !== $service_at ) {
	echo wp_date( 'c', $service_at );
}

Defined in includes/features/reminder-emails/functions.php, line 112.

rpress_reminder_check_order()#

Works out what to do with an order's reminder at a given moment.

Returns a state of sent, disabled, skip, wait or send, plus the service time and the time the reminder is due when known. Skips non-orders, ASAP orders, payment or order statuses that should not be reminded, orders placed inside the reminder window and times already passed. The result passes through the rpress_reminder_check_order filter; statuses are filterable with rpress_reminder_payment_statuses and rpress_reminder_skip_order_statuses.

rpress_reminder_check_order( $payment_id, $now = null )

Parameters

ParameterTypeDefaultDescription
$payment_idintRequiredOrder ID.
$nowint|nullnullUnix time; defaults to rpress_reminder_now().

Returns array: Array with state (send, wait, sent, skip or disabled), reason (string, set when skipped), reminder_at (int) and service_at (int). The two times are 0 when unknown.

Example

$check = rpress_reminder_check_order( 123 );
if ( 'wait' === $check['state'] ) {
	echo wp_date( 'c', $check['reminder_at'] );
}

Defined in includes/features/reminder-emails/functions.php, line 137.

rpress_reminder_schedule()#

Schedules or re-schedules the single cron event for an order's reminder.

Clears any pending event for the order, then schedules one at the reminder time when the state is wait, or immediately when the state is send. Uses the rpress_send_order_reminder cron hook.

rpress_reminder_schedule( $payment_id )

Parameters

ParameterTypeDefaultDescription
$payment_idintRequiredOrder ID.

Example

rpress_reminder_schedule( 123 );

Defined in includes/features/reminder-emails/functions.php, line 195.

rpress_reminder_cron_callback()#

Cron callback that sends a due reminder or re-schedules one that is not yet due.

Runs on the rpress_send_order_reminder hook. Sends when the state is send, and schedules a new event for the reminder time when the state is wait, for example after the lead time was shortened.

rpress_reminder_cron_callback( $payment_id )

Parameters

ParameterTypeDefaultDescription
$payment_idintRequiredOrder ID.

Internal. Defined in includes/features/reminder-emails/functions.php, line 216.

rpress_reminder_send()#

Sends an order's reminder email if it is due.

Safe to call repeatedly. The order is claimed with the _rpress_reminder_sent meta first so cron and the init fallback cannot both send. If sending fails the claim is removed so a later check can retry. On success it clears the pending cron event, adds an order note and fires the rpress_reminder_sent action.

rpress_reminder_send( $payment_id, $now = null )

Parameters

ParameterTypeDefaultDescription
$payment_idintRequiredOrder ID.
$nowint|nullnullUnix time; defaults to rpress_reminder_now().

Returns bool: True when the email was sent by this call.

Example

if ( rpress_reminder_send( 123 ) ) {
	// The reminder went out.
}

Defined in includes/features/reminder-emails/functions.php, line 233.

rpress_reminder_process_due()#

Sends all reminders that are due now.

Does nothing when the reminder is disabled. Queries unsent, non-ASAP orders for today and for the date the lead time reaches, in batches, and calls rpress_reminder_send() for each. Batch size and page cap are filterable with rpress_reminder_batch_size and rpress_reminder_max_pages.

rpress_reminder_process_due( $now = null )

Parameters

ParameterTypeDefaultDescription
$nowint|nullnullUnix time; defaults to rpress_reminder_now().

Returns int[]: IDs of the orders reminded.

Example

$sent = rpress_reminder_process_due();

Defined in includes/features/reminder-emails/functions.php, line 264.

rpress_reminder_init_fallback()#

Checks for due reminders on init for sites where WP-Cron is disabled.

Hooked to init at priority 99. Skips while installing or importing and when the reminder is disabled. Runs rpress_reminder_process_due() at most once per interval, five minutes by default, filterable with rpress_reminder_fallback_interval. The last check time is stored in the rpress_reminder_last_check option.

rpress_reminder_init_fallback()

Internal. Defined in includes/features/reminder-emails/functions.php, line 337.

rpress_reminder_queue()#

Collects order IDs whose reminder needs re-scheduling at the end of the request.

Keeps a per-request static queue. Passing an ID adds it; passing null only reads the queue.

rpress_reminder_queue( $payment_id = null )

Parameters

ParameterTypeDefaultDescription
$payment_idint|nullnullOrder ID to queue, or null to read the queue.

Returns int[]: Order IDs currently in the queue.

Internal. Defined in includes/features/reminder-emails/functions.php, line 364.

rpress_reminder_queue_order()#

Queues an order for re-scheduling after a status change or completed payment.

Hooked to rpress_update_order_status, rpress_complete_purchase and rpress_update_payment_status. Ignores empty values and objects.

rpress_reminder_queue_order( $payment_id )

Parameters

ParameterTypeDefaultDescription
$payment_idintRequiredOrder ID.

Internal. Defined in includes/features/reminder-emails/functions.php, line 378.

rpress_reminder_queue_on_meta()#

Queues an order when its service date or time meta is added or updated.

Hooked to added_post_meta and updated_post_meta. Reacts only to _rpress_delivery_date and _rpress_delivery_time.

rpress_reminder_queue_on_meta( $meta_id, $object_id, $meta_key )

Parameters

ParameterTypeDefaultDescription
$meta_idintRequiredMeta ID.
$object_idintRequiredPost ID.
$meta_keystringRequiredMeta key.

Internal. Defined in includes/features/reminder-emails/functions.php, line 395.

rpress_reminder_flush_queue()#

Schedules the reminder of every queued order at the end of the request.

Hooked to shutdown. Calls rpress_reminder_schedule() for each queued ID that is an order.

rpress_reminder_flush_queue()

Internal. Defined in includes/features/reminder-emails/functions.php, line 408.

rpress_reminder_unschedule_deleted()#

Removes an order's pending reminder event when the order is deleted.

Hooked to before_delete_post. Ignores posts that are not orders.

rpress_reminder_unschedule_deleted( $post_id )

Parameters

ParameterTypeDefaultDescription
$post_idintRequiredPost ID.

Internal. Defined in includes/features/reminder-emails/functions.php, line 423.

rpress_reminder_message()#

Returns the reminder sentence for an order, worded for pickup or delivery.

Includes the order number and the service time in the site time format. Delivery orders get a scheduled-for-delivery wording, others a will-be-ready wording. The result passes through the rpress_reminder_message filter.

rpress_reminder_message( $payment_id, $service_at )

Parameters

ParameterTypeDefaultDescription
$payment_idintRequiredOrder ID.
$service_atintRequiredUnix time of the service.

Returns string: The reminder sentence.

Defined in includes/features/reminder-emails/functions.php, line 437.

rpress_reminder_send_email()#

Builds and sends the reminder email using the store's email template.

Fails when the order or a valid customer email is missing. Switches to the order's WPML language when available, replaces {reminder_message}, {service_time} and {service_date} plus the standard email tags, and sends through RPRESS()->emails. The previous heading and headers of the shared mailer are restored afterwards. Filters: rpress_reminder_headers and rpress_reminder_email_message.

rpress_reminder_send_email( $payment_id, $service_at )

Parameters

ParameterTypeDefaultDescription
$payment_idintRequiredOrder ID.
$service_atintRequiredUnix time of the service.

Returns bool: True when the email was sent.

Note: Does not check whether the reminder is due or already sent; use rpress_reminder_send() for that.

Internal. Defined in includes/features/reminder-emails/functions.php, line 457.

Was this page helpful?