1. Documentation
  2. Plugins
  3. WooCommerce
  4. Extensions
  5. WooCommerce Product Search
  6. Developer Documentation

Actions

woocommerce_product_search_deactivate ↑ Back to top

This action is invoked when the plugin is about to be deactivated and before it deletes its own data. It does not imply that its data will be deleted.

woocommerce_product_search_indexer_index_start ↑ Back to top

This action is triggered before the search engine’s indexer starts indexing a product. The action provides one argument, the product’s ID.

Arguments:

  • $post_id int the product’s ID

woocommerce_product_search_indexer_index_end ↑ Back to top

This action is triggered after the search engine’s indexer has completed indexing a product. The action provides one argument, the product’s ID.

Arguments:

  • $post_id int the product’s ID

woocommerce_product_search_service_post_ids_for_request ↑ Back to top

This action allows to modify the set of eligible product IDs for a given request that is handled by the search engine. The action has two arguments, the first is an array of product IDs passed by reference, the second is an array that reflects the context of the request handled by the search engine.

A typical application of this action would be to include or remove certain product IDs based on criteria that are unknown to the search engine itself.

Arguments:

  • &$product_ids array product IDs that the search engine provides as results for the request
  • $context array the context for the request handled by the search engine

Functions hooked on this action must not return any value but modify the array of $product_ids directly.

  • If $product_ids is an empty array, all products are eligible as results for the request.
  • If $product_ids is an array that only contains -1, no products are eligible as results for the request.

Outline for an example application:

add_action( 'woocommerce_product_search_service_post_ids_for_request', 'my_customized_post_ids_for_request', 10, 2 );
function my_customized_post_ids_for_request( &$product_ids, $context ) {
    // Here you could retrieve additional product IDs that should be included:
    $additional_product_ids = ...;
    $product_ids = array_merge( $product_ids, $additional_product_ids );
}

Implementations should take care to assure optimum performance.

woocommerce_product_search_signal_filter_response ↑ Back to top

This action indicates that the system is handling a request to deliver its filter response.

This API action allows plugins and themes to be compatible with its live filters and selectively disable lazy loading.

Plugins and themes that wish to be compatible, should listen to the woocommerce_product_search_signal_filter_response action and disable their lazy loading features during the request when this action is invoked.

A typical example would be:

add_action( 'woocommerce_product_search_signal_filter_response', 'my_theme_disable_lazy_loading' );

function my_theme_disable_lazy_loading() {
// disable lazy loading during this request
}

When the action is triggered, the theme/plugin should not apply lazy loading so it does not interfere with the results pulled in dynamically by the search engine’s live filters.

woocommerce_before_{$loop_name}_loop ↑ Back to top

This action applies when the plugin’s [woocommerce_product_filter_products] shortcode is used or when its woocommerce_product_filter_products() function is called to display products. It is invoked just before entering the product loop and provides the shortcode or function attributes as the action’s $atts argument.

Arguments:

$atts array rendering options

woocommerce_after_{$loop_name}_loop ↑ Back to top

This action applies when the plugin’s [woocommerce_product_filter_products] shortcode is used or when its woocommerce_product_filter_products() function is called to display products. It is invoked just after the product loop and provides the shortcode or function attributes as the action’s $atts argument.

Arguments:

$atts array rendering options

woocommerce_{$loop_name}_loop_no_results ↑ Back to top

This action applies when the plugin’s [woocommerce_product_filter_products] shortcode is used or when its woocommerce_product_filter_products() function is called to display products. It is invoked when there are no products to show in the product loop and provides the shortcode or function attributes as the action’s $atts argument.

Arguments:

$atts array rendering options

WooCommerce - the most customizable eCommerce platform for building your online business.

  • 30 day money back guarantee
  • Support teams across the world
  • Safe & Secure online payment