Add untrash order hook (COT/HPOS). (#35087)
This commit is contained in:
parent
bf61c6bf19
commit
c2be5a6253
|
@ -0,0 +1,4 @@
|
|||
Significance: patch
|
||||
Type: tweak
|
||||
|
||||
Introduces new hook `woocommerce_untrash_order` as a COT/HPOS analog to `untrash_post`.
|
|
@ -1838,6 +1838,16 @@ FROM $order_meta_table
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Fires before an order is restored from the trash.
|
||||
*
|
||||
* @since 7.2.0
|
||||
*
|
||||
* @param int $order_id Order ID.
|
||||
* @param string $previous_status The status of the order before it was trashed.
|
||||
*/
|
||||
do_action( 'woocommerce_untrash_order', $order->get_id(), $previous_status );
|
||||
|
||||
$order->set_status( $previous_status );
|
||||
$order->save();
|
||||
|
||||
|
@ -1845,6 +1855,7 @@ FROM $order_meta_table
|
|||
if ( $previous_status === $order->get_status() ) {
|
||||
$order->delete_meta_data( '_wp_trash_meta_status' );
|
||||
$order->delete_meta_data( '_wp_trash_meta_time' );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue