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_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\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_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_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_request_intercepted

Hook: wcf_before_request_intercepted - Fires before the request is intercepted.

Arguments

  • $this (\Barn2\Plugin\WC_Filters\Request): instance of the Request class.

Example

add_action( 'wcf_before_request_intercepted', 'my_wcf_before_request_intercepted' );
function my_wcf_before_request_intercepted( $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...
}

wcf_prefilled_query

Hook: allow developers to add custom logic while filtering a prefilled query.

Arguments

  • $query (\WP_Query): WP query instance
  • $filters (\Barn2\Plugin\WC_Filters\Dependencies\Illuminate\Support\Collection): filters collection
  • $orderby (string): order parameter
  • $post_ids (array): list of filtered posts.

Example

add_action( 'wcf_prefilled_query', 'my_wcf_prefilled_query', 10, 4 );
function my_wcf_prefilled_query( $query, $filters, $orderby, $post_ids ) {
	// your code here...
}

Filters

wcf_all_choices_counts_bypass

Filter: allow developers to return a custom count for the
filter when counting specific posts.

Arguments

  • $bypass (bool): whether or not to return a custom value.
  • $filter (\Barn2\Plugin\WC_Filters\Traits\Filter):
  • $post_ids (array):

Example

add_filter( 'wcf_all_choices_counts_bypass', 'my_wcf_all_choices_counts_bypass', 10, 3 );
function my_wcf_all_choices_counts_bypass( $bypass, $filter, $post_ids ) {
	// your code to alter $bypass here...

	return $bypass;
}

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):

wcf_bypass_loop_tag

Filter: allows third parties to bypass the loop tag.

Arguments

  • $bypass (bool): whether to bypass the loop tag.
  • $query (\WP_Query): the current query.
  • $display (self): the current display instance.

Example

add_filter( 'wcf_bypass_loop_tag', 'my_wcf_bypass_loop_tag', 10, 3 );
function my_wcf_bypass_loop_tag( $bypass, $query, $display ) {
	// your code to alter $bypass here...

	return $bypass;
}

wcf_cached_query_found_posts

Filter the found posts count
for the cached query.

Arguments

  • $found (int): the found posts count.
  • $wp_query (\WP_Query): the query object.

Example

add_filter( 'wcf_cached_query_found_posts', 'my_wcf_cached_query_found_posts', 10, 2 );
function my_wcf_cached_query_found_posts( $found, $wp_query ) {
	// your code to alter $found here...

	return $found;
}

wcf_custom_field_range_data

Filter the range data for custom field filters.

Arguments

  • $data (array): The range data (min, max, unit).
  • $filter_id (int): The ID of the current filter.
  • $this (\Barn2\Plugin\WC_Filters\Model\Filters\Custom_Field): The current Custom_Field instance.

Example

add_filter( 'wcf_custom_field_range_data', 'my_wcf_custom_field_range_data', 10, 3 );
function my_wcf_custom_field_range_data( $data, $filter_id, $this ) {
	// your code to alter $data here...

	return $data;
}

wcf_custom_field_store_data

Filter the store data for custom field filters.

Arguments

  • $data (array): The store data.
  • $filter_id (int): The ID of the current filter.
  • $this (\Barn2\Plugin\WC_Filters\Model\Filters\Custom_Field): The current Custom_Field instance.

Example

add_filter( 'wcf_custom_field_store_data', 'my_wcf_custom_field_store_data', 10, 3 );
function my_wcf_custom_field_store_data( $data, $filter_id, $this ) {
	// your code to alter $data here...

	return $data;
}

wcf_default_excluded_terms

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

Arguments

  • $taxonomy (string):

Example

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

	return $taxonomy;
}

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_dropdowns_searchable_mobile

Example

add_filter( 'wcf_dropdowns_searchable_mobile', 'my_wcf_dropdowns_searchable_mobile' );
function my_wcf_dropdowns_searchable_mobile() {
	// your code here...
}

wcf_elementor_force_enqueue_of_wpt_asset

Filter: force enqueue of the WPT asset if the shortcode widget is used.

Arguments

  • $enqueue (bool): Whether to force enqueue or not.
  • $widgets (array): List of widgets used on the page.

Example

add_filter( 'wcf_elementor_force_enqueue_of_wpt_asset', 'my_wcf_elementor_force_enqueue_of_wpt_asset', 10, 2 );
function my_wcf_elementor_force_enqueue_of_wpt_asset( $enqueue, $widgets ) {
	// your code to alter $enqueue here...

	return $enqueue;
}

wcf_elementor_tax_query_load_all_posts

Filter: determine if all posts should be loaded
when viewing a taxonomy archive page.

Arguments

  • $should_load_all_posts (bool):
  • $wp_query (\WP_Query):

Example

add_filter( 'wcf_elementor_tax_query_load_all_posts', 'my_wcf_elementor_tax_query_load_all_posts', 10, 2 );
function my_wcf_elementor_tax_query_load_all_posts( $should_load_all_posts, $wp_query ) {
	// your code to alter $should_load_all_posts here...

	return $should_load_all_posts;
}

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_fallback_attach_search_query_to_filter

Filter: allows developers to adjust the search query
that is attached to the filter instance
during the fallback request.

This filter is mainly used internally for our own integrations, but it's also available for developers to use.

Arguments

  • $search_query (mixed): the search query to attach to the filter instance.
  • $instance (\Barn2\Plugin\WC_Filters\Model\Filter): the filter instance.
  • $parameters (\Barn2\Plugin\WC_Filters\Dependencies\Illuminate\Support\Collection): the collection of parameters.

wcf_fallback_mode

Filter: determine if fallback mode should be used throughout the plugin.

Arguments

  • $fallback (bool):

Example

add_filter( 'wcf_fallback_mode', 'my_wcf_fallback_mode' );
function my_wcf_fallback_mode( $fallback ) {
	// your code to alter $fallback here...

	return $fallback;
}

wcf_filter_restrict_variable_product_terms

Example

add_filter( 'wcf_filter_restrict_variable_product_terms', 'my_wcf_filter_restrict_variable_product_terms' );
function my_wcf_filter_restrict_variable_product_terms() {
	// your code here...
}

wcf_filtered_post_ids

Filter: allows developers to adjust the array of retrieved products
after it has queried the database and found the appropriate results.

Arguments

  • $post_ids (array): products that have been found
  • $filters (\Barn2\Plugin\WC_Filters\Dependencies\Illuminate\Support\Collection): filters that have been used to retrieve the products

Example

add_filter( 'wcf_filtered_post_ids', 'my_wcf_filtered_post_ids', 10, 2 );
function my_wcf_filtered_post_ids( $post_ids, $filters ) {
	// your code to alter $post_ids here...

	return $post_ids;
}

wcf_filtered_post_ids_query_args

Filter: allows developers to adjust the arguments for the
query that loads the filtered results.

Arguments

  • $args (array):

Example

add_filter( 'wcf_filtered_post_ids_query_args', 'my_wcf_filtered_post_ids_query_args' );
function my_wcf_filtered_post_ids_query_args( $args ) {
	// your code to alter $args here...

	return $args;
}

wcf_get_choices_counts_post_ids

Example

add_filter( 'wcf_get_choices_counts_post_ids', 'my_wcf_get_choices_counts_post_ids' );
function my_wcf_get_choices_counts_post_ids() {
	// your code here...
}

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_search_base_url

Filter: allows developers to modify the search base URL.

Arguments

  • $url (string):

Example

add_filter( 'wcf_get_search_base_url', 'my_wcf_get_search_base_url' );
function my_wcf_get_search_base_url( $url ) {
	// your code to alter $url here...

	return $url;
}

wcf_global_inject_fallback

Filter to determine if the fallback mode should be injected.

Used internally to prevent the fallback mode from being injected in certain cases.

Arguments

  • $should_inject_fallback (bool): Whether the fallback mode should be injected.

wcf_horizontal_minimum_images

Example

add_filter( 'wcf_horizontal_minimum_images', 'my_wcf_horizontal_minimum_images' );
function my_wcf_horizontal_minimum_images() {
	// your code here...
}

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\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_is_main_query

Filter: allows developers to adjust the conditions
used to determine whether or not the query being processed
is a WCF main query.

Arguments

  • $is_main_query (bool):
  • $query (\WP_Query):

Example

add_filter( 'wcf_is_main_query', 'my_wcf_is_main_query', 10, 2 );
function my_wcf_is_main_query( $is_main_query, $query ) {
	// your code to alter $is_main_query here...

	return $is_main_query;
}

wcf_is_pagination_disabled

Example

add_filter( 'wcf_is_pagination_disabled', 'my_wcf_is_pagination_disabled' );
function my_wcf_is_pagination_disabled() {
	// your code here...
}

wcf_pricing_api_products_ids

Filter: allows adjustments to the list of product ids used to retrieve
that max price for the pricing slider filter on taxonomy pages.

Arguments

  • $products_ids (array):

Example

add_filter( 'wcf_pricing_api_products_ids', 'my_wcf_pricing_api_products_ids' );
function my_wcf_pricing_api_products_ids( $products_ids ) {
	// your code to alter $products_ids here...

	return $products_ids;
}

wcf_product_table_integration_assets_enabled

Filter the assets enabled flag for the integration of the product table plugin.

Arguments

  • $enabled (bool):

Example

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

	return $enabled;
}

wcf_product_table_integration_display_additional_elements

Determine if the additional elements should be displayed.

Arguments

  • $should_display_additional_elements (bool): default is true.

Example

add_filter( 'wcf_product_table_integration_display_additional_elements', 'my_wcf_product_table_integration_display_additional_elements' );
function my_wcf_product_table_integration_display_additional_elements( $should_display_additional_elements ) {
	// your code to alter $should_display_additional_elements here...

	return $should_display_additional_elements;
}

wcf_results_count

Filter: allows developers to adjust the arguments
used to generate the WooCommerce result-count template
output.

Arguments

  • $args (array):
  • $query (bool|\WP_Query): optional wp query instance that might be sent through in some cases.
  • $post_ids (array): list of post ids that might be sent through in some cases.
  • $filters (null|\Barn2\Plugin\WC_Filters\Dependencies\Illuminate\Support\Collection): list of filters possibly sent through during request.

Example

add_filter( 'wcf_results_count', 'my_wcf_results_count', 10, 4 );
function my_wcf_results_count( $args, $query, $post_ids, $filters ) {
	// your code to alter $args here...

	return $args;
}

wcf_shop_filters_shortcode

Filter: Allows modification of the shop filters shortcode before output

Arguments

  • $shortcode (string): The product filters shortcode
  • $group (int): The group ID

Example

add_filter( 'wcf_shop_filters_shortcode', 'my_wcf_shop_filters_shortcode', 10, 2 );
function my_wcf_shop_filters_shortcode( $shortcode, $group ) {
	// your code to alter $shortcode here...

	return $shortcode;
}

wcf_should_exclude_variations_from_counts

Filter: determine if variations should be excluded from counts.

Arguments

  • $should_exclude_variations (bool): default is false.

Example

add_filter( 'wcf_should_exclude_variations_from_counts', 'my_wcf_should_exclude_variations_from_counts' );
function my_wcf_should_exclude_variations_from_counts( $should_exclude_variations ) {
	// your code to alter $should_exclude_variations here...

	return $should_exclude_variations;
}

wcf_should_load_frontend_assets

Filter: allows third parties to disable or enable the frontend assets loading.

Arguments

  • $should_load (bool): whether to load the frontend assets.

Example

add_filter( 'wcf_should_load_frontend_assets', 'my_wcf_should_load_frontend_assets' );
function my_wcf_should_load_frontend_assets( $should_load ) {
	// your code to alter $should_load here...

	return $should_load;
}

wcf_should_restrict_choices_counts

Filter: allows modification of logic used to restrict or merge results.

Arguments

  • $should_restrict (bool): Whether or not to restrict results.
  • $filter (\Barn2\Plugin\WC_Filters\Traits\Filter): The filter instance.
  • $prefilling (bool): Whether or not prefilling is enabled.
  • $other_filters (array): Other filters used in the query.

Example

add_filter( 'wcf_should_restrict_choices_counts', 'my_wcf_should_restrict_choices_counts', 10, 4 );
function my_wcf_should_restrict_choices_counts( $should_restrict, $filter, $prefilling, $other_filters ) {
	// your code to alter $should_restrict here...

	return $should_restrict;
}

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_taxonomy_filter_attribute_terms_list

Filter: allows developers to modify the list of found terms
generated by the Attribute filter type.

Arguments

  • $terms (array):
  • $filter (\Barn2\Plugin\WC_Filters\Model\Filters\Attribute):

Example

add_filter( 'wcf_taxonomy_filter_attribute_terms_list', 'my_wcf_taxonomy_filter_attribute_terms_list', 10, 2 );
function my_wcf_taxonomy_filter_attribute_terms_list( $terms, $filter ) {
	// your code to alter $terms here...

	return $terms;
}

wcf_taxonomy_filter_ranged_terms_list

Filter: allows developers to modify the list of found terms generated
by the Ranged Attribute filter type.

Arguments

  • $output (array): the list of terms.
  • $taxonomy (string): the taxonomy slug.
  • $terms (array): the original list of terms.
  • $post_id (string): the post ID.

Example

add_filter( 'wcf_taxonomy_filter_ranged_terms_list', 'my_wcf_taxonomy_filter_ranged_terms_list', 10, 4 );
function my_wcf_taxonomy_filter_ranged_terms_list( $output, $taxonomy, $terms, $post_id ) {
	// your code to alter $output here...

	return $output;
}

wcf_taxonomy_filter_terms_list

Filter: allows developers to modify the list of found terms
generated by the Taxonomy filter type.

Arguments

  • $terms (array):
  • $filter (\Barn2\Plugin\WC_Filters\Model\Filters\Taxonomy):

Example

add_filter( 'wcf_taxonomy_filter_terms_list', 'my_wcf_taxonomy_filter_terms_list', 10, 2 );
function my_wcf_taxonomy_filter_terms_list( $terms, $filter ) {
	// your code to alter $terms here...

	return $terms;
}

wcf_taxonomy_json_terms_args

Filter: allows modification of the arguments used to retrieve terms
for the images taxonomy filter.

Example

add_filter( 'wcf_taxonomy_json_terms_args', 'my_wcf_taxonomy_json_terms_args' );
function my_wcf_taxonomy_json_terms_args() {
	// your code here...
}

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;
}

wcf_wc_shortcode_inject_fallback

Load the assets specific to this integration.

Example

add_filter( 'wcf_wc_shortcode_inject_fallback', 'my_wcf_wc_shortcode_inject_fallback' );
function my_wcf_wc_shortcode_inject_fallback() {
	// your code here...
}

Related Articles

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