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
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
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
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
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
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
wcf_indexer_complete
Hook: allow developers to hook into the indexing process once it's complete.
Example
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
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
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
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
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
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
wcf_default_excluded_terms
Get the list of default excluded terms that should not be
displayed inside filters.
Arguments
$taxonomy
(string):
Example
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
wcf_dropdowns_searchable_mobile
Example
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
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
wcf_exclude_uncategorised
Get the list of default excluded terms that should not be
displayed inside filters.
Arguments
$taxonomy
(string):
Example
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
wcf_filter_restrict_variable_product_terms
Example
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
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
wcf_get_choices_counts_post_ids
Example
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
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
wcf_get_search_base_url
Filter: allows developers to modify the search base URL.
Arguments
$url
(string):
Example
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
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
wcf_indexer_skip_hidden_products
Determine if hidden products should be skipped during indexing.
Example
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
wcf_is_pagination_disabled
Example
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
wcf_product_table_integration_assets_enabled
Filter the assets enabled flag for the integration of the product table plugin.
Arguments
$enabled
(bool):
Example
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
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
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
wcf_should_exclude_variations_from_counts
Filter: determine if variations should be excluded from counts.
Arguments
$should_exclude_variations
(bool): default is false.
Example
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
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
wcf_supported_sources
Filter: makes the supported sources list filterable.
Arguments
$list
(array):
Example
wcf_supported_sources_filter_types
Filter: allows overriding of the label and supported sources of
each input filter type.
Arguments
$types
(array):
Example
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
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
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
wcf_taxonomy_json_terms_args
Filter: allows modification of the arguments used to retrieve terms
for the images taxonomy filter.
Example
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
wcf_wc_shortcode_inject_fallback
Load the assets specific to this integration.