WC_Order_Data_Store_CPT::untrash_orderpublicWC 1.0

Attempts to restore the specified order back to its original status (after having been trashed).

Метод класса: WC_Order_Data_Store_CPT{}

Хуков нет.

Возвращает

true|false. If the operation was successful.

Использование

$WC_Order_Data_Store_CPT = new WC_Order_Data_Store_CPT();
$WC_Order_Data_Store_CPT->untrash_order( $order ): bool;
$order(WC_Order) (обязательный)
The order to be untrashed.

Код WC_Order_Data_Store_CPT::untrash_order() WC 11.0.1

public function untrash_order( WC_Order $order ): bool {
	if ( ! wp_untrash_post( $order->get_id() ) ) {
		return false;
	}

	// Restoring the order triggers a status transition (from 'trash' back to its previous
	// status). WC_Emails dispatches customer notifications on those transitions, so suppress
	// email dispatch for this order while we restore to avoid re-notifying the customer
	// about an order they were already emailed about. The status transition actions
	// themselves still fire, so any 3rd-party code hooked into them keeps working.
	$suspended_email_dispatch = $this->suspend_transactional_email_dispatch( $order->get_id() );

	try {
		$order->set_status( get_post_field( 'post_status', $order->get_id() ) );
		$saved = (bool) $order->save();
	} finally {
		$this->restore_transactional_email_dispatch( $suspended_email_dispatch );
	}

	return $saved;
}