Automattic\WooCommerce\Internal\Admin\Agentic

AgenticWebhookManager::should_trigger_webhookprivateWC 1.0

Check if webhook should be triggered for this order.

Method of the class: AgenticWebhookManager{}

No Hooks.

Returns

true|false. True if webhook should be triggered.

Usage

// private - for code of main (parent) class only
$result = $this->should_trigger_webhook( $order );
$order(WC_Order) (required)
Order object.

AgenticWebhookManager::should_trigger_webhook() code WC 10.4.3

private function should_trigger_webhook( $order ) {
	// Only trigger for orders with an Agentic checkout session ID.
	$checkout_session_id = $order->get_meta( OrderMetaKey::AGENTIC_CHECKOUT_SESSION_ID );
	if ( empty( $checkout_session_id ) ) {
		return false;
	}

	// Don't trigger for draft orders.
	if (
		in_array(
			$order->get_status(),
			array(
				OrderStatus::CHECKOUT_DRAFT,
				OrderStatus::DRAFT,
				OrderStatus::AUTO_DRAFT,
			),
			true
		)
	) {
		return false;
	}

	return true;
}