WC_AJAX::mark_order_status
Mark an order with a status.
Method of the class: WC_AJAX{}
Hooks from the method
Returns
null. Nothing (null).
Usage
$result = WC_AJAX::mark_order_status();
WC_AJAX::mark_order_status() WC AJAX::mark order status code WC 10.5.0
public static function mark_order_status() {
if ( current_user_can( 'edit_shop_orders' ) && check_admin_referer( 'woocommerce-mark-order-status' ) && isset( $_GET['status'], $_GET['order_id'] ) ) {
$status = sanitize_text_field( wp_unslash( $_GET['status'] ) );
$order = wc_get_order( absint( wp_unslash( $_GET['order_id'] ) ) );
if ( wc_is_order_status( 'wc-' . $status ) && $order ) {
// Initialize payment gateways in case order has hooked status transition actions.
WC()->payment_gateways();
$order->update_status( $status, '', true );
do_action( 'woocommerce_order_edit_status', $order->get_id(), $status );
}
}
wp_safe_redirect( wp_get_referer() ? wp_get_referer() : admin_url( 'edit.php?post_type=shop_order' ) );
exit;
}