Automattic\WooCommerce\Internal\PushNotifications\Triggers

NewOrderNotificationTrigger::on_new_orderpublicWC 10.7.0

Handles the woocommerce_new_order hook.

Method of the class: NewOrderNotificationTrigger{}

No Hooks.

Returns

null. Nothing (null).

Usage

$NewOrderNotificationTrigger = new NewOrderNotificationTrigger();
$NewOrderNotificationTrigger->on_new_order( $order_id, $order ): void;
$order_id(int) (required)
The order ID.
$order(WC_Order) (required)
The order object.

Changelog

Since 10.7.0 Introduced.

NewOrderNotificationTrigger::on_new_order() code WC 10.7.0

public function on_new_order( int $order_id, WC_Order $order ): void {
	if ( ! in_array( $order->get_status(), self::NOTIFIABLE_STATUSES, true ) ) {
		return;
	}

	wc_get_container()->get( PendingNotificationStore::class )->add(
		new NewOrderNotification( $order_id )
	);
}