WC_Order::set_status() public WC 3.0.0
Set order status.
{} It's a method of the class: WC_Order{}
Hooks from the method
Return
Array.
Usage
$WC_Order = new WC_Order(); $WC_Order->set_status( $new_status, $note, $manual_update );
- $new_status(string) (required)
- Status to change the order to. No internal wc- prefix is required.
- $note(string)
- Optional note to add.
- $manual_update(true/false)
- Is this a manual order status change?.
Changelog
Since 3.0.0 | Introduced. |
Code of WC_Order::set_status() WC Order::set status WC 5.0.0
public function set_status( $new_status, $note = '', $manual_update = false ) {
$result = parent::set_status( $new_status );
if ( true === $this->object_read && ! empty( $result['from'] ) && $result['from'] !== $result['to'] ) {
$this->status_transition = array(
'from' => ! empty( $this->status_transition['from'] ) ? $this->status_transition['from'] : $result['from'],
'to' => $result['to'],
'note' => $note,
'manual' => (bool) $manual_update,
);
if ( $manual_update ) {
do_action( 'woocommerce_order_edit_status', $this->get_id(), $result['to'] );
}
$this->maybe_set_date_paid();
$this->maybe_set_date_completed();
}
return $result;
}