1. Home
  2. Knowledge Base
  3. WooCommerce Product Filters
  4. Developer Documentation

WooCommerce Product Filters Action and Filters

WooCommerce Product Filters contains a number of hooks that you can use to customize the plugin's behavior.

Please note that these code snippets are aimed at developers. If you feel comfortable using them, our article on how to use code snippets can serve as a helpful guide. If you don't know how to use them, then you should ask your developer. If you don't have one then you can use our plugin customization service.

Actions

wcf_after_create_wc_product_query

Fires after the WooCommerce product query is created.

Arguments

  • $query (\WP_Query): The query object.
  • $wc_query (\WC_Query): The WC_Query object.

Example

add_action( 'wcf_after_create_wc_product_query', 'my_wcf_after_create_wc_product_query', 10, 2 );
function my_wcf_after_create_wc_product_query( $query, $wc_query ) {
	// your code here...
}

wcf_after_override_shop_template

Fires after the shop template is overridden.

Arguments

  • $wp_query (\Barn2\Plugin\WC_Filters\Services\WP_Query): The WP_Query object.

Example

add_action( 'wcf_after_override_shop_template', 'my_wcf_after_override_shop_template' );
function my_wcf_after_override_shop_template( $wp_query ) {
	// your code here...
}

wcf_after_prepare_results

Allow for custom logic after preparing results
of a product query.

Arguments

  • $query (\Barn2\Plugin\WC_Filters\Query): The query object.

Example

add_action( 'wcf_after_prepare_results', 'my_wcf_after_prepare_results' );
function my_wcf_after_prepare_results( $query ) {
	// your code here...
}

wcf_after_product_delete

Action: hook into the product delete process and
after the index has been cleared of data related to
the product that has been deleted.

Arguments

  • $post_id (string|int):

Example

add_action( 'wcf_after_product_delete', 'my_wcf_after_product_delete' );
function my_wcf_after_product_delete( $post_id ) {
	// your code here...
}

wcf_after_product_import

Action: hook into the csv import process,
fires after the product has been imported & indexed.

Arguments

  • $product (object): WC instance of a product

Example

add_action( 'wcf_after_product_import', 'my_wcf_after_product_import' );
function my_wcf_after_product_import( $product ) {
	// your code here...
}

wcf_after_product_index

Action: hook into the indexing process after a product
has been indexed.

Arguments

  • $post_id (string|int): the id of the product
  • $product (object): instance of a WC product
  • $filters (array): collection of filters for which the index is being generated
  • $indexer (\Barn2\Plugin\WC_Filters\Services\Indexer): instance of the indexer

Example

add_action( 'wcf_after_product_index', 'my_wcf_after_product_index', 10, 4 );
function my_wcf_after_product_index( $post_id, $product, $filters, $indexer ) {
	// your code here...
}

wcf_after_product_loop

Hook: wcf_after_product_loop

Arguments

  • $products (array): Array of WC_Product objects

Example

add_action( 'wcf_after_product_loop', 'my_wcf_after_product_loop' );
function my_wcf_after_product_loop( $products ) {
	// your code here...
}

wcf_after_product_save

Action: hook into the `save_post` WP hook but after
we've executed our custom logic that indexes products.

Arguments

  • $product_id (string|int):
  • $product (object): WC instance of a product

Example

add_action( 'wcf_after_product_save', 'my_wcf_after_product_save', 10, 2 );
function my_wcf_after_product_save( $product_id, $product ) {
	// your code here...
}

wcf_after_render_products

Fires after the product filters shortcode is rendered.

Arguments

  • $this (\Barn2\Plugin\WC_Filters\Services\Renderer): The current renderer instance

Example

add_action( 'wcf_after_render_products', 'my_wcf_after_render_products' );
function my_wcf_after_render_products( $this ) {
	// your code here...
}

wcf_after_setup_query

Fires after the query is setup.

Arguments

  • $query (\WP_Query): The query object.
  • $this (\Barn2\Plugin\WC_Filters\Services\Renderer): The renderer instance.

Example

add_action( 'wcf_after_setup_query', 'my_wcf_after_setup_query', 10, 2 );
function my_wcf_after_setup_query( $query, $this ) {
	// your code here...
}

wcf_batch_index_complete

Hook: allow developers to hook into the batch indexing process once a batch is complete.

Arguments

  • $post_ids (array): list of posts that were processed.
  • $offset (string|int): wp query offeset processed.
  • $limit (string|int): batch amount processed.

Example

add_action( 'wcf_batch_index_complete', 'my_wcf_batch_index_complete', 10, 3 );
function my_wcf_batch_index_complete( $post_ids, $offset, $limit ) {
	// your code here...
}

wcf_before_override_shop_template

Fires before the shop template is overridden.

Arguments

  • $wp_query (\Barn2\Plugin\WC_Filters\Services\WP_Query): The WP_Query object.

Example

add_action( 'wcf_before_override_shop_template', 'my_wcf_before_override_shop_template' );
function my_wcf_before_override_shop_template( $wp_query ) {
	// your code here...
}

wcf_before_prepare_results

Allow for custom logic before preparing results
of a product query.

Arguments

  • $query (\Barn2\Plugin\WC_Filters\Query): The query object.

Example

add_action( 'wcf_before_prepare_results', 'my_wcf_before_prepare_results' );
function my_wcf_before_prepare_results( $query ) {
	// your code here...
}

wcf_before_product_loop

Hook: wcf_before_product_loop

Arguments

  • $products (array): Array of WC_Product objects

Example

add_action( 'wcf_before_product_loop', 'my_wcf_before_product_loop' );
function my_wcf_before_product_loop( $products ) {
	// your code here...
}

wcf_before_render_products

Fires before the product filters shortcode is rendered.

Arguments

  • $this (\Barn2\Plugin\WC_Filters\Services\Renderer): The current renderer instance

Example

add_action( 'wcf_before_render_products', 'my_wcf_before_render_products' );
function my_wcf_before_render_products( $this ) {
	// your code here...
}

wcf_before_setup_query

Fires before the query is setup.

Arguments

  • $query (\WP_Query): The query object.
  • $this (\Barn2\Plugin\WC_Filters\Services\Renderer): The renderer instance.

Example

add_action( 'wcf_before_setup_query', 'my_wcf_before_setup_query', 10, 2 );
function my_wcf_before_setup_query( $query, $this ) {
	// your code here...
}

wcf_indexer_complete

Hook: allow developers to hook into the indexing process once it's complete.

Example

add_action( 'wcf_indexer_complete', 'my_wcf_indexer_complete' );
function my_wcf_indexer_complete() {
	// your code here...
}

Fires after the search is performed.

Arguments

  • $response (array): The response.
  • $request (\WP_REST_Request): The REST request object.

Example

add_action( 'wcf_search_api_after_search', 'my_wcf_search_api_after_search', 10, 2 );
function my_wcf_search_api_after_search( $response, $request ) {
	// your code here...
}

Fires before the search is performed.

Arguments

  • $request (\WP_REST_Request): The REST request object.
  • $this (\Barn2\Plugin\WC_Filters\Services\Search_Api): The Search_Api instance.

Example

add_action( 'wcf_search_api_before_search', 'my_wcf_search_api_before_search', 10, 2 );
function my_wcf_search_api_before_search( $request, $this ) {
	// your code here...
}

wcf_shop_loop

Hook: wcf_shop_loop

Arguments

  • $product_id (int): Current product ID

Example

add_action( 'wcf_shop_loop', 'my_wcf_shop_loop' );
function my_wcf_shop_loop( $product_id ) {
	// your code here...
}

wcf_sorting_before_apply_product_ordering

Filter the query before applying product ordering.

Arguments

  • $query (\WP_Query): The query object.
  • $product_ids (array): The array of product IDs to sort.
  • $order_by (string): The ordering criteria.

Example

add_action( 'wcf_sorting_before_apply_product_ordering', 'my_wcf_sorting_before_apply_product_ordering', 10, 3 );
function my_wcf_sorting_before_apply_product_ordering( $query, $product_ids, $order_by ) {
	// your code here...
}

Filters

wcf_avada_filters_group_attributes

Filter the attributes used when rendering the filters group widget.

Arguments

  • $attributes (array): The attributes that will be used to render the widget.

Example

add_filter( 'wcf_avada_filters_group_attributes', 'my_wcf_avada_filters_group_attributes' );
function my_wcf_avada_filters_group_attributes( $attributes ) {
	// your code to alter $attributes here...

	return $attributes;
}

wcf_avada_widget_attributes

Filter the attributes used when rendering the product list widget.

Arguments

  • $attributes (array): The attributes that will be used to render the widget.

Example

add_filter( 'wcf_avada_widget_attributes', 'my_wcf_avada_widget_attributes' );
function my_wcf_avada_widget_attributes( $attributes ) {
	// your code to alter $attributes here...

	return $attributes;
}

wcf_batch_index_chunk_size

Filter: allows developers to change the amount of posts processed with each batch.

Default is 30.

Arguments

  • $chunk_size (string|int):

Example

add_filter( 'wcf_batch_index_chunk_size', 'my_wcf_batch_index_chunk_size' );
function my_wcf_batch_index_chunk_size( $chunk_size ) {
	// your code to alter $chunk_size here...

	return $chunk_size;
}

wcf_bricks_filters_group_attributes

Filter the attributes used when rendering the filters group element.

Arguments

  • $attributes (array): The attributes that will be used to render the element.

Example

add_filter( 'wcf_bricks_filters_group_attributes', 'my_wcf_bricks_filters_group_attributes' );
function my_wcf_bricks_filters_group_attributes( $attributes ) {
	// your code to alter $attributes here...

	return $attributes;
}

wcf_bricks_widget_attributes

Filter the attributes used when rendering the product list widget.

Arguments

  • $attributes (array): The attributes that will be used to render the widget.

Example

add_filter( 'wcf_bricks_widget_attributes', 'my_wcf_bricks_widget_attributes' );
function my_wcf_bricks_widget_attributes( $attributes ) {
	// your code to alter $attributes here...

	return $attributes;
}

wcf_default_excluded_terms

Filter: wcf_default_excluded_terms
Allows to add or remove terms from the default excluded terms list.

Arguments

  • $terms (array): The default excluded terms.
  • $taxonomy (string): The taxonomy.

Example

add_filter( 'wcf_default_excluded_terms', 'my_wcf_default_excluded_terms', 10, 2 );
function my_wcf_default_excluded_terms( $terms, $taxonomy ) {
	// your code to alter $terms here...

	return $terms;
}

wcf_design_settings

Hook: wcf_design_settings allows third parties to add their own design settings or modify the existing ones.

Arguments

  • $settings (array):

Example

add_filter( 'wcf_design_settings', 'my_wcf_design_settings' );
function my_wcf_design_settings( $settings ) {
	// your code to alter $settings here...

	return $settings;
}

wcf_disable_default_loop_priority

Filters the priority for disabling the default WooCommerce loop.

Arguments

  • $priority (int): The priority for the action hook. Default 10.

Example

add_filter( 'wcf_disable_default_loop_priority', 'my_wcf_disable_default_loop_priority' );
function my_wcf_disable_default_loop_priority( $priority ) {
	// your code to alter $priority here...

	return $priority;
}

wcf_divi_group_widget_attributes

Filter the attributes used when rendering the filters group widget.

Arguments

  • $attributes (array): The attributes that will be used to render the widget.

Example

add_filter( 'wcf_divi_group_widget_attributes', 'my_wcf_divi_group_widget_attributes' );
function my_wcf_divi_group_widget_attributes( $attributes ) {
	// your code to alter $attributes here...

	return $attributes;
}

wcf_divi_widget_attributes

Filter the attributes used when rendering the product list widget.

Arguments

  • $attributes (array): The attributes that will be used to render the widget.

Example

add_filter( 'wcf_divi_widget_attributes', 'my_wcf_divi_widget_attributes' );
function my_wcf_divi_widget_attributes( $attributes ) {
	// your code to alter $attributes here...

	return $attributes;
}

wcf_elementor_widget_attributes

Filter the attributes used when rendering the product list widget.

Arguments

  • $attributes (array): The attributes that will be used to render the widget.

Example

add_filter( 'wcf_elementor_widget_attributes', 'my_wcf_elementor_widget_attributes' );
function my_wcf_elementor_widget_attributes( $attributes ) {
	// your code to alter $attributes here...

	return $attributes;
}

wcf_exclude_uncategorised

Get the list of default excluded terms that should not be
displayed inside filters.

Arguments

  • $taxonomy (string):

Example

add_filter( 'wcf_exclude_uncategorised', 'my_wcf_exclude_uncategorised' );
function my_wcf_exclude_uncategorised( $taxonomy ) {
	// your code to alter $taxonomy here...

	return $taxonomy;
}

wcf_filter_groups

Hook: filters the cached list of filter groups
retrieved from the database.

Arguments

  • $groups (array): List of filter groups.

Example

add_filter( 'wcf_filter_groups', 'my_wcf_filter_groups' );
function my_wcf_filter_groups( $groups ) {
	// your code to alter $groups here...

	return $groups;
}

wcf_filter_indexed_terms

Filter the indexed terms retrieved from the database.

Arguments

  • $values (array): The indexed terms.
  • $filter (\Barn2\Plugin\WC_Filters\Traits\Filter): The filter object.
  • $posts (array): The posts to look up.

Example

add_filter( 'wcf_filter_indexed_terms', 'my_wcf_filter_indexed_terms', 10, 3 );
function my_wcf_filter_indexed_terms( $values, $filter, $posts ) {
	// your code to alter $values here...

	return $values;
}

wcf_get_all_products_results

Filter the final array of product IDs.

Arguments

  • $products (array): Array of product IDs.
  • $this (\Barn2\Plugin\WC_Filters\Query): The current Query instance.

Example

add_filter( 'wcf_get_all_products_results', 'my_wcf_get_all_products_results', 10, 2 );
function my_wcf_get_all_products_results( $products, $this ) {
	// your code to alter $products here...

	return $products;
}

wcf_get_option

Filters the retrieval of an option.

Arguments

  • $value (mixed): the original value.
  • $key (string): the key of the option being retrieved.
  • $default (mixed): default value if nothing is found.

Example

add_filter( 'wcf_get_option', 'my_wcf_get_option', 10, 3 );
function my_wcf_get_option( $value, $key, $default ) {
	// your code to alter $value here...

	return $value;
}

wcf_get_option_{$key}

Get an option
Looks to see if the specified setting exists, returns default if not.

Arguments

  • $key (string): the key to retrieve.
  • $default (mixed): default value to use in case option is not available.

Example

add_filter( 'wcf_get_option_{$key}', 'my_wcf_get_option_key', 10, 2 );
function my_wcf_get_option_key( $key, $default ) {
	// your code to alter $key here...

	return $key;
}

wcf_get_ordering_args

Filter the ordering arguments for the query.

Arguments

  • $args (array): The ordering arguments.
  • $orderby (string): The orderby parameter.
  • $order (string): The order parameter (ASC or DESC).

Example

add_filter( 'wcf_get_ordering_args', 'my_wcf_get_ordering_args', 10, 3 );
function my_wcf_get_ordering_args( $args, $orderby, $order ) {
	// your code to alter $args here...

	return $args;
}

wcf_has_product_collection

Filter whether the current page has a product collection.

Arguments

  • $has_collection (bool): Whether the page has a product collection.

Example

add_filter( 'wcf_has_product_collection', 'my_wcf_has_product_collection' );
function my_wcf_has_product_collection( $has_collection ) {
	// your code to alter $has_collection here...

	return $has_collection;
}

wcf_index_row

Filter: allow hooks to bypass the row insertion by returning anything else other than an array.

Arguments

  • $params (array): indexed data for the facet
  • $indexer (\Barn2\Plugin\WC_Filters\Services\Indexer): instance of the indexer

Example

add_filter( 'wcf_index_row', 'my_wcf_index_row', 10, 2 );
function my_wcf_index_row( $params, $indexer ) {
	// your code to alter $params here...

	return $params;
}

wcf_indexer_skip_hidden_products

Determine if hidden products should be skipped during indexing.

Example

add_filter( 'wcf_indexer_skip_hidden_products', 'my_wcf_indexer_skip_hidden_products' );
function my_wcf_indexer_skip_hidden_products() {
	// your code here...
}

wcf_loop_columns

Render products using WooCommerce's standard template system

Arguments

  • $products (array): Array of WC_Product objects

Example

add_filter( 'wcf_loop_columns', 'my_wcf_loop_columns' );
function my_wcf_loop_columns( $products ) {
	// your code to alter $products here...

	return $products;
}

wcf_matching_posts

Filter the matching posts before they are returned.

Arguments

  • $posts (array): The array of matching post IDs.
  • $this (\Barn2\Plugin\WC_Filters\Query): The current Query instance.

Example

add_filter( 'wcf_matching_posts', 'my_wcf_matching_posts', 10, 2 );
function my_wcf_matching_posts( $posts, $this ) {
	// your code to alter $posts here...

	return $posts;
}

wcf_no_products_notice_html

Filter the "no products found" notice HTML

Arguments

  • $notice_html (string): The HTML output of the notice
  • $message (string): The message text being displayed

Example

add_filter( 'wcf_no_products_notice_html', 'my_wcf_no_products_notice_html', 10, 2 );
function my_wcf_no_products_notice_html( $notice_html, $message ) {
	// your code to alter $notice_html here...

	return $notice_html;
}

wcf_pre_get_all_products

Filter whether to short-circuit the get_all_products method.

Arguments

  • $pre_posts (null|array): Array of post IDs to return, or null to continue with normal execution.
  • $this (\Barn2\Plugin\WC_Filters\Query): The current Query instance.

Example

add_filter( 'wcf_pre_get_all_products', 'my_wcf_pre_get_all_products', 10, 2 );
function my_wcf_pre_get_all_products( $pre_posts, $this ) {
	// your code to alter $pre_posts here...

	return $pre_posts;
}

wcf_product_loop_wrapper_classes

Render products using WooCommerce's standard template system

Arguments

  • $products (array): Array of WC_Product objects

Example

add_filter( 'wcf_product_loop_wrapper_classes', 'my_wcf_product_loop_wrapper_classes' );
function my_wcf_product_loop_wrapper_classes( $products ) {
	// your code to alter $products here...

	return $products;
}

wcf_product_table_page_has_shortcode

Filter the page has product table shortcode flag.

Arguments

  • $enabled (bool): Whether the page has a product table shortcode.

Example

add_filter( 'wcf_product_table_page_has_shortcode', 'my_wcf_product_table_page_has_shortcode' );
function my_wcf_product_table_page_has_shortcode( $enabled ) {
	// your code to alter $enabled here...

	return $enabled;
}

wcf_query_possible_choices

Filter the possible choices for filters before they are stored
and before they are returned to the frontend.

Arguments

  • $results (array): Array of possible filter choices from the database query.
  • $this (\Barn2\Plugin\WC_Filters\Query): The current Query instance.

Example

add_filter( 'wcf_query_possible_choices', 'my_wcf_query_possible_choices', 10, 2 );
function my_wcf_query_possible_choices( $results, $this ) {
	// your code to alter $results here...

	return $results;
}

wcf_query_posts_per_page

Filter the number of posts per page for the data/logic layer.

This filter is used for pagination calculations and metadata in the Query results. It affects the pagination info returned to the frontend and uses integrations array as the data source (different from the renderer's shortcode attributes).

Arguments

  • $posts_per_page (int): The calculated number of posts per page.
  • $query (\Barn2\Plugin\WC_Filters\Query): The current Query instance.

Example

add_filter( 'wcf_query_posts_per_page', 'my_wcf_query_posts_per_page', 10, 2 );
function my_wcf_query_posts_per_page( $posts_per_page, $query ) {
	// your code to alter $posts_per_page here...

	return $posts_per_page;
}

wcf_query_results

Filter the query results before they are returned.

Arguments

  • $results (array): The query results.
  • $this (\Barn2\Plugin\WC_Filters\Query): The current Query instance.

Example

add_filter( 'wcf_query_results', 'my_wcf_query_results', 10, 2 );
function my_wcf_query_results( $results, $this ) {
	// your code to alter $results here...

	return $results;
}

wcf_query_sanitize_integrations

Filter the sanitized integrations.

Arguments

  • $sanitized (array): The sanitized integrations.
  • $integrations (array): The original integrations.

Example

add_filter( 'wcf_query_sanitize_integrations', 'my_wcf_query_sanitize_integrations', 10, 2 );
function my_wcf_query_sanitize_integrations( $sanitized, $integrations ) {
	// your code to alter $sanitized here...

	return $sanitized;
}

wcf_query_sanitize_query_args

Filter the sanitized query arguments.

Arguments

  • $sanitized (array): The sanitized query arguments.
  • $query_args (array): The original query arguments.

Example

add_filter( 'wcf_query_sanitize_query_args', 'my_wcf_query_sanitize_query_args', 10, 2 );
function my_wcf_query_sanitize_query_args( $sanitized, $query_args ) {
	// your code to alter $sanitized here...

	return $sanitized;
}

wcf_remove_catalog_ordering_priority

Filters the priority for removing the default WooCommerce catalog ordering.

Arguments

  • $priority (int): The priority for the remove_action hook. Default 30.

Example

add_filter( 'wcf_remove_catalog_ordering_priority', 'my_wcf_remove_catalog_ordering_priority' );
function my_wcf_remove_catalog_ordering_priority( $priority ) {
	// your code to alter $priority here...

	return $priority;
}

wcf_render_elements_priority

Filters the priority for rendering WCF elements after the shop loop.

Arguments

  • $priority (int): The priority for the action hook. Default 10.

Example

add_filter( 'wcf_render_elements_priority', 'my_wcf_render_elements_priority' );
function my_wcf_render_elements_priority( $priority ) {
	// your code to alter $priority here...

	return $priority;
}

wcf_render_products_override

Filter to allow third-party plugins to override product rendering.

If this filter returns a non-null value, that value will be returned instead of the default rendering logic.

Arguments

  • $output (null|string): The output to return (null to continue with default rendering)
  • $products (array): Array of WC_Product objects
  • $this (\Barn2\Plugin\WC_Filters\Services\Renderer): The current renderer instance

Example

add_filter( 'wcf_render_products_override', 'my_wcf_render_products_override', 10, 3 );
function my_wcf_render_products_override( $output, $products, $this ) {
	// your code to alter $output here...

	return $output;
}

wcf_renderer_query_posts_per_page

Filter the number of posts per page for the WooCommerce query/display layer.

This filter is used specifically for setting up the WP_Query that fetches products for rendering. It affects the actual WooCommerce product display and uses shortcode attributes as the data source.

Arguments

  • $posts_per_page (int): The calculated number of posts per page (columns * rows)
  • $this (\Barn2\Plugin\WC_Filters\Services\Renderer): The current renderer instance

Example

add_filter( 'wcf_renderer_query_posts_per_page', 'my_wcf_renderer_query_posts_per_page', 10, 2 );
function my_wcf_renderer_query_posts_per_page( $posts_per_page, $this ) {
	// your code to alter $posts_per_page here...

	return $posts_per_page;
}

wcf_renderer_sanitize_shortcode_attributes

Filter the sanitized shortcode attributes.

Arguments

  • $sanitized (array): The sanitized attributes.
  • $attributes (array): The original attributes.

Example

add_filter( 'wcf_renderer_sanitize_shortcode_attributes', 'my_wcf_renderer_sanitize_shortcode_attributes', 10, 2 );
function my_wcf_renderer_sanitize_shortcode_attributes( $sanitized, $attributes ) {
	// your code to alter $sanitized here...

	return $sanitized;
}

wcf_search_api_get_order_by

Filter the order_by parameter for the search.

Arguments

  • $order_by (string|null): The order_by parameter.
  • $request (\WP_REST_Request): The REST request object.

Example

add_filter( 'wcf_search_api_get_order_by', 'my_wcf_search_api_get_order_by', 10, 2 );
function my_wcf_search_api_get_order_by( $order_by, $request ) {
	// your code to alter $order_by here...

	return $order_by;
}

wcf_search_api_search_response

Filter the response for the search request.

Arguments

  • $response (array): The response.
  • $request (\WP_REST_Request): The REST request object.

Example

add_filter( 'wcf_search_api_search_response', 'my_wcf_search_api_search_response', 10, 2 );
function my_wcf_search_api_search_response( $response, $request ) {
	// your code to alter $response here...

	return $response;
}

wcf_search_get_groups

Filter the list of group IDs that should be used for the search.

Arguments

  • $groups (array): The list of group IDs.
  • $request (\WP_REST_Request): The REST request object.

Example

add_filter( 'wcf_search_get_groups', 'my_wcf_search_get_groups', 10, 2 );
function my_wcf_search_get_groups( $groups, $request ) {
	// your code to alter $groups here...

	return $groups;
}

wcf_search_get_integrations

Filter the integrations for the search.

Arguments

  • $integrations (array): The integrations.
  • $request (\WP_REST_Request): The REST request object.

Example

add_filter( 'wcf_search_get_integrations', 'my_wcf_search_get_integrations', 10, 2 );
function my_wcf_search_get_integrations( $integrations, $request ) {
	// your code to alter $integrations here...

	return $integrations;
}

wcf_search_get_parameters

Filter the parameters for the search.

Arguments

  • $parameters (array): The parameters.
  • $request (\WP_REST_Request): The REST request object.

Example

add_filter( 'wcf_search_get_parameters', 'my_wcf_search_get_parameters', 10, 2 );
function my_wcf_search_get_parameters( $parameters, $request ) {
	// your code to alter $parameters here...

	return $parameters;
}

wcf_search_get_query_args

Filter the query arguments for the search.

Arguments

  • $query_args (array): The query arguments.
  • $request (\WP_REST_Request): The REST request object.

Example

add_filter( 'wcf_search_get_query_args', 'my_wcf_search_get_query_args', 10, 2 );
function my_wcf_search_get_query_args( $query_args, $request ) {
	// your code to alter $query_args here...

	return $query_args;
}

wcf_search_get_reset

Filter the reset flag for the search.

Arguments

  • $reset (bool): Whether this is a reset request.
  • $request (\WP_REST_Request): The REST request object.

Example

add_filter( 'wcf_search_get_reset', 'my_wcf_search_get_reset', 10, 2 );
function my_wcf_search_get_reset( $reset, $request ) {
	// your code to alter $reset here...

	return $reset;
}

wcf_search_requires_rendering

Filter to determine if the search requires rendering.

Arguments

  • $requires_rendering (bool): Whether the search requires rendering.
  • $request (\WP_REST_Request): The REST request object.

Example

add_filter( 'wcf_search_requires_rendering', 'my_wcf_search_requires_rendering', 10, 2 );
function my_wcf_search_requires_rendering( $requires_rendering, $request ) {
	// your code to alter $requires_rendering here...

	return $requires_rendering;
}

wcf_should_inspect_query

Filter whether the query should be inspected.

Arguments

  • $should_inspect (bool): Whether the query should be inspected.
  • $query (\WP_Query): The query object.
  • $instance (\WC_Query): The WC_Query instance.

Example

add_filter( 'wcf_should_inspect_query', 'my_wcf_should_inspect_query', 10, 3 );
function my_wcf_should_inspect_query( $should_inspect, $query, $instance ) {
	// your code to alter $should_inspect here...

	return $should_inspect;
}

wcf_should_override_shop_template

Filters whether the shop template should be overridden.

Arguments

  • $override (bool): Whether the shop template should be overridden.

Example

add_filter( 'wcf_should_override_shop_template', 'my_wcf_should_override_shop_template' );
function my_wcf_should_override_shop_template( $override ) {
	// your code to alter $override here...

	return $override;
}

wcf_supported_sources

Filter: makes the supported sources list filterable.

Arguments

  • $list (array):

Example

add_filter( 'wcf_supported_sources', 'my_wcf_supported_sources' );
function my_wcf_supported_sources( $list ) {
	// your code to alter $list here...

	return $list;
}

wcf_supported_sources_filter_types

Filter: allows overriding of the label and supported sources of
each input filter type.

Arguments

  • $types (array):

Example

add_filter( 'wcf_supported_sources_filter_types', 'my_wcf_supported_sources_filter_types' );
function my_wcf_supported_sources_filter_types( $types ) {
	// your code to alter $types here...

	return $types;
}

wcf_update_option

Filter the final value of an option before being saved into the database.

Arguments

  • $value (mixed): the value about to be saved.
  • $key (string): the key of the option that is being saved.

Example

add_filter( 'wcf_update_option', 'my_wcf_update_option', 10, 2 );
function my_wcf_update_option( $value, $key ) {
	// your code to alter $value here...

	return $value;
}

JavaScript Events

wcf:filter:remove

Event fired when a filter is removed. The event detail contains the filter's slug identifier and the specific value being removed from the filter.

Event Detail

  • slug (string): The filter's slug identifier (e.g. 'category', 'price_range')
  • value (string|number): The specific value being removed from the filter. Could be an ID for taxonomies or a formatted string for other filter types

Example

// Listen for filter removal
document.addEventListener('wcf:filter:remove', (event) => {
	const { slug, value } = event.detail;
	console.log(`Removing filter: ${slug} with value: ${value}`);
	// Handle filter removal...
});

wcf:filter:afterRemoved

Event fired after a filter has been successfully removed. The event detail contains the filter's slug identifier and the specific value that was removed from the filter.

Event Detail

  • slug (string): The filter's slug identifier (e.g. 'category', 'price_range')
  • value (string|number): The specific value that was removed from the filter. Could be an ID for taxonomies or a formatted string for other filter types

Example

// Listen for after filter removal
document.addEventListener('wcf:filter:afterRemoved', (event) => {
	const { slug, value } = event.detail;
	console.log(`Filter removed: ${slug} with value: ${value}`);
	// Handle post-removal logic...
});

wcf:products:beforeRender

Event fired before products are rendered. This allows you to modify the response or prepare the UI before products are displayed.

Event Detail

  • response (Object): The AJAX response containing products HTML and metadata
  • isInfiniteLoading (boolean): Whether infinite loading is currently active

Example

// Listen for before products render
document.addEventListener('wcf:products:beforeRender', (event) => {
	const { response, isInfiniteLoading } = event.detail;
	console.log('About to render products', { response, isInfiniteLoading });
	// Prepare UI or modify response before rendering...
});

wcf:products:afterRender

Event fired after products have been rendered. This allows you to perform actions on the newly rendered products or update the UI.

Event Detail

  • response (Object): The AJAX response containing products HTML and metadata
  • isInfiniteLoading (boolean): Whether infinite loading was active during rendering
  • container (HTMLElement): The products container element that was updated

Example

// Listen for after products render
document.addEventListener('wcf:products:afterRender', (event) => {
	const { response, isInfiniteLoading, container } = event.detail;
	console.log('Products rendered', { response, isInfiniteLoading, container });
	// Initialize components, update counters, etc...
});

wcf:products:beforeScroll

Event fired before scrolling to products. This allows you to prepare the UI or cancel the scroll action if needed.

Event Detail

  • offset (number): Scroll offset in pixels that will be applied
  • isInfiniteLoading (boolean): Whether infinite loading is currently active

Example

// Listen for before scroll to products
document.addEventListener('wcf:products:beforeScroll', (event) => {
	const { offset, isInfiniteLoading } = event.detail;
	console.log('About to scroll to products', { offset, isInfiniteLoading });
	// Prepare scroll animation or modify offset...
});

wcf:products:afterScroll

Event fired after scrolling to products is complete. This allows you to perform actions after the scroll animation finishes.

Event Detail

  • offset (number): Scroll offset that was used in pixels
  • isInfiniteLoading (boolean): Whether infinite loading was active during scrolling
  • targetElement (HTMLElement): The element that was scrolled to
  • scrollPosition (number): The final scroll position after scrolling

Example

// Listen for after scroll to products
document.addEventListener('wcf:products:afterScroll', (event) => {
	const { offset, isInfiniteLoading, targetElement, scrollPosition } = event.detail;
	console.log('Scrolled to products', { offset, isInfiniteLoading, targetElement, scrollPosition });
	// Update UI, focus elements, etc...
});

wcf:url:beforeUpdate

Event fired before URL parameters are updated. This allows you to modify the parameters or cancel the URL update.

Event Detail

  • url (string): The current URL before parameters are updated
  • params (Object): The parameters that will be added to the URL
  • prefix (string): The prefix being used for the parameters

Example

// Listen for before URL parameters update
document.addEventListener('wcf:url:beforeUpdate', (event) => {
	const { url, params, prefix } = event.detail;
	console.log('About to update URL', { url, params, prefix });
	// Modify parameters or prepare for URL change...
});

wcf:url:afterUpdate

Event fired after URL parameters have been updated. This allows you to perform actions after the URL has changed.

Event Detail

  • url (string): The new URL after parameters are updated
  • params (Object): The parameters that were added to the URL
  • prefix (string): The prefix that was used for the parameters

Example

// Listen for after URL parameters update
document.addEventListener('wcf:url:afterUpdate', (event) => {
	const { url, params, prefix } = event.detail;
	console.log('URL updated', { url, params, prefix });
	// Update analytics, notify other components, etc...
});

wcf:url:beforeDelete

Event fired before URL parameters are deleted. This allows you to prepare for the parameter removal or cancel the deletion.

Event Detail

  • url (string): The current URL before parameters are deleted

Example

// Listen for before URL parameters deletion
document.addEventListener('wcf:url:beforeDelete', (event) => {
	const { url } = event.detail;
	console.log('About to delete URL parameters', { url });
	// Prepare for parameter removal...
});

wcf:url:afterDelete

Event fired after URL parameters have been deleted. This allows you to perform actions after the parameters have been removed from the URL.

Event Detail

  • url (string): The current URL after parameters are deleted

Example

// Listen for after URL parameters deletion
document.addEventListener('wcf:url:afterDelete', (event) => {
	const { url } = event.detail;
	console.log('URL parameters deleted', { url });
	// Update UI, reset components, etc...
});

wcf:filters:clearAll

Event fired to signal clearing all active filters. This event is used to communicate between components when all filters should be reset.

Event Detail

  • No event detail data is provided with this event

Example

// Listen for clear all filters
document.addEventListener('wcf:filters:clearAll', (event) => {
	console.log('Clearing all filters');
	// Reset all filter components, clear UI state, etc...
});

wcf:mobile:toggleDrawer

Event fired to toggle the mobile drawer open or closed. This event allows components to communicate drawer state changes and optionally specify the desired state.

Event Detail

  • isOpen (boolean|undefined): Optional. If provided, specifies the desired state of the drawer. If true, drawer should open. If false, drawer should close. If not provided, the drawer will toggle its current state.

Example

// Listen for mobile drawer toggle
document.addEventListener('wcf:mobile:toggleDrawer', (event) => {
	const { isOpen } = event.detail;
	console.log('Toggle mobile drawer', { isOpen });
	// Handle drawer state change...
});

Related Articles

If searching the knowledge base hasn't answered your question, please contact support.