WooCommerce plugin docs / Hooks

Developer hooks

Public filters and actions found in the plugin. Internal classes may change; prefer these hooks.

Filter aiwsa_feature_is_licensed (default true for non-core slugs) lets a licence plugin hide Pro-style features. Core slugs search and cart_recovery cannot be licence-locked.


Actions

HookWhenArguments
aiwsa_register_servicesContainer buildContainer $container
aiwsa_initPlugin initPlugin $plugin
aiwsa_loadedAfter bootnone
aiwsa_register_providersProvider registryProvider_Registry $registry
aiwsa_register_toolsTool registryregistry
aiwsa_rest_routes_registeredAfter REST registerWP_REST_Server
aiwsa_activatedAfter activationnone
aiwsa_deactivatedAfter deactivationnone
aiwsa_conversation_startedNew conversationConversation
aiwsa_conversation_expiredTTL expirystring $uuid
aiwsa_conversation_erasedErasedstring $uuid, $reason
aiwsa_guest_promotedGuest merged to userstring $uuid, int $user_id
aiwsa_cleanup_completedDaily cleanup$removed
aiwsa_provider_request_failedHTTP failureProvider_Exception, string $provider_id, string $trace
aiwsa_analytics_eventEvent emitted$type, $session_id, $payload
aiwsa_cart_recovery_before_sendBefore mail$cart, $step
aiwsa_cart_recovery_after_sendAfter mail$cart, $step, bool $ok
aiwsa_cart_recovery_recoveredOrder placed$cart, int $order_id
aiwsa_cart_recovery_unsubscribedUnsub$cart

Filters (selection)

Enablement and features

add_filter( 'aiwsa_is_enabled', fn( bool $on, string $context ) => $on, 10, 2 );
add_filter( 'aiwsa_feature_is_licensed', fn( bool $ok, string $slug ) => $ok, 10, 2 );
add_filter( 'aiwsa_feature_is_allowed', fn( bool $ok, string $slug ) => $ok, 10, 2 );
add_filter( 'aiwsa_tool_is_available', fn( bool $ok, $tool, $context ) => $ok, 10, 3 );
add_filter( 'aiwsa_approved_tool_names', fn( array $names ) => $names );
add_filter( 'aiwsa_ai_configured', fn( bool $configured ) => $configured );

AI / HTTP

add_filter( 'aiwsa_provider', fn( $provider, string $id ) => $provider, 10, 2 );
add_filter( 'aiwsa_provider_timeout', fn( int $t, string $id, bool $x ) => $t, 10, 3 );
add_filter( 'aiwsa_provider_http_args', fn( array $args, string $id, string $method ) => $args, 10, 3 );
add_filter( 'aiwsa_provider_allowed_hosts', fn( array $hosts ) => $hosts );
add_filter( 'aiwsa_prompt_fragments', fn( array $fragments, $context ) => $fragments, 10, 2 );
add_filter( 'aiwsa_transport', fn( string $transport ) => $transport ); // post|sse

Search

add_filter( 'aiwsa_search_parsed_intent', fn( array $arr, $criteria ) => $arr, 10, 2 );
add_filter( 'aiwsa_search_criteria', fn( $result, $criteria ) => $result, 10, 2 );
add_filter( 'aiwsa_search_candidate_ids', fn( array $ids, $criteria ) => $ids, 10, 2 );
add_filter( 'aiwsa_search_results', fn( array $ids, $criteria ) => $ids, 10, 2 );
add_filter( 'aiwsa_search_rank_score', fn( int $score, int $id, $criteria ) => $score, 10, 3 );
add_filter( 'aiwsa_search_explanation', fn( string $text, $product, $criteria ) => $text, 10, 3 );
add_filter( 'aiwsa_search_intent_prompt', fn( string $system, string $query ) => $system, 10, 2 );
add_filter( 'aiwsa_search_intent_response', fn( string $text, string $query ) => $text, 10, 2 );
add_filter( 'aiwsa_semantic_search_available', fn( bool $on ) => false ); // default false
add_filter( 'aiwsa_semantic_search_ids', fn( array $ids, array $criteria ) => $ids, 10, 2 );

REST / security / session

add_filter( 'aiwsa_rest_namespace', fn( string $ns ) => $ns ); // default aiwsa/v1
add_filter( 'aiwsa_rest_permission', fn( $result, string $route, $request ) => $result, 10, 3 );
add_filter( 'aiwsa_rate_limits', fn( array $limits, $actor ) => $limits, 10, 2 );
add_filter( 'aiwsa_widget_config', fn( array $config ) => $config ); // never add secrets
add_filter( 'aiwsa_conversation_ttl', fn( int $ttl ) => $ttl );
add_filter( 'aiwsa_retention_days', fn( int $days, string $type ) => $days, 10, 2 );
add_filter( 'aiwsa_client_ip', fn( string $ip ) => $ip );
add_filter( 'aiwsa_redaction_patterns', fn( array $patterns ) => $patterns );
add_filter( 'aiwsa_log_level', fn( string $level ) => $level );
add_filter( 'aiwsa_log_context', fn( array $ctx, string $level, string $msg ) => $ctx, 10, 3 );
add_filter( 'aiwsa_cache_enabled', fn( bool $on, string $group ) => $on, 10, 2 );
add_filter( 'aiwsa_cache_ttl', fn( int $ttl, string $group, string $key ) => $ttl, 10, 3 );
add_filter( 'aiwsa_max_add_to_cart_quantity', fn( int $max, int $product_id ) => $max, 10, 2 );
add_filter( 'aiwsa_response_language', fn( $decision, $message, $stored, $detect ) => $decision, 10, 4 );

Orders

add_filter( 'aiwsa_resolve_order_number', fn( int $id, string $number ) => $id, 10, 2 );
add_filter( 'aiwsa_order_tracking', fn( $tracking, $order ) => $tracking, 10, 2 );

Quick Actions

add_filter( 'aiwsa_quick_action_types', fn( array $types ) => $types );
add_filter( 'aiwsa_ai_action_templates', fn( array $templates ) => $templates );
add_filter( 'aiwsa_ai_action_config', fn( array $item ) => $item );

Cart recovery

add_filter( 'aiwsa_cart_recovery_url', fn( string $url, string $uuid ) => $url, 10, 2 );
add_filter( 'aiwsa_cart_recovery_subject', fn( string $subject, $cart ) => $subject, 10, 2 );
add_filter( 'aiwsa_cart_recovery_body', fn( string $html, $cart ) => $html, 10, 2 );
add_filter( 'aiwsa_cart_recovery_redirect', fn( string $url, string $dest ) => $url, 10, 2 );
add_filter( 'aiwsa_cart_recovery_prompt', fn( string $base, $step ) => $base, 10, 2 );
add_filter( 'aiwsa_cart_recovery_mailer', fn( $mailer, $cart ) => $mailer, 10, 2 );
add_filter( 'aiwsa_cart_recovery_cart_eligible', fn( bool $ok, $cart, $rules ) => $ok, 10, 3 );
add_filter( 'aiwsa_cart_recovery_delay', fn( int $due, $step, $cart ) => $due, 10, 3 );

JavaScript events

Dispatched from assets/js/widget.js after a successful cart mutation:

document.addEventListener( 'aiwsa.cart.updated', function ( event ) {
  console.log( event.detail.cart );
} );

Also triggers wc_fragment_refresh on document.body so mini-cart fragments can refresh.

There is no public aiwsa.ready event in the current widget.


Example: hide the assistant on checkout

add_filter( 'aiwsa_is_enabled', function ( bool $enabled, string $context ) {
	if ( 'widget' === $context && function_exists( 'is_checkout' ) && is_checkout() ) {
		return false;
	}
	return $enabled;
}, 10, 2 );

Example: semantic IDs (optional)

add_filter( 'aiwsa_semantic_search_available', '__return_true' );
add_filter( 'aiwsa_semantic_search_ids', function ( array $ids, array $criteria ) {
	// Return product IDs only. Plugin re-loads live WooCommerce products.
	return $ids;
}, 10, 2 );