Add untrash order hook (COT/HPOS). (#35087)

This commit is contained in:
Barry Hughes 2022-10-20 09:23:29 -07:00 committed by GitHub
parent bf61c6bf19
commit c2be5a6253
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,4 @@
Significance: patch
Type: tweak
Introduces new hook `woocommerce_untrash_order` as a COT/HPOS analog to `untrash_post`.

View File

@ -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;
}