Skip to content
Docs
Get RestroPress

Action

rpress_update_order_status

Updated
On this page

Fires after an order's status has been saved.

Runs once the new status has been stored in the _order_status meta (and, for the completed status, after the payment has been marked as paid). Core listeners use it to send customer notifications, broadcast real-time updates and clear cached counts. Use it for any follow-up work triggered by a status change.

Parameters#

ParameterTypeDescription
$payment_idintThe order (payment) ID.
$new_statusstringThe new order status slug, for example accepted, processing, ready, transit, completed or cancelled.

Example#

function my_on_order_status_change( $payment_id, $new_status ) {
	if ( 'ready' === $new_status ) {
		update_post_meta( $payment_id, 'my_ready_at', time() );
	}
}
add_action( 'rpress_update_order_status', 'my_on_order_status_change', 10, 2 );

Notes#

Fired from rpress_update_order_status_with_meta() (after the database transaction has committed, so slow work belongs here rather than in meta hooks) and from the REST orders controller. The REST callbacks only fire it when it has not already fired in the request, and there $payment_id and $new_status are the raw request values.

Source#

Fired from:

  • includes/admin/orders/actions.php (line 114), in rpress_update_order_status_with_meta()
  • includes/admin/orders/actions.php (line 182), in rpress_update_order_status_with_meta()
  • includes/rest-api/Controllers/Version1/class-rp-rest-orders-v1-controller.php (line 109), in RP_REST_Orders_V1_Controller::update_order_status()
  • includes/rest-api/Controllers/Version1/class-rp-rest-orders-v1-controller.php (line 650), in RP_REST_Orders_V1_Controller::create_item()
  • includes/rest-api/Controllers/Version1/class-rp-rest-orders-v1-controller.php (line 772), in RP_REST_Orders_V1_Controller::update_item()

See also#

Was this page helpful?