product_search_limit
↑ Back to topThis filter allows to alter the limit on the number of results produced for the Product Search Field.
Arguments:
$limit int
the number of results
Return:
int
the number of results
single_term_title
↑ Back to topAllows to modify the category name displayed for categories shown on the Product Search Field.
Arguments:
$name string
the category name
Return:
string
the category name
widget_title
↑ Back to topAllows to modify the widget title displayed on the various widgets.
Arguments:
$title string
the title
Return:
string
the title
woocommerce_product_filter_placeholder
↑ Back to topModifies the placeholder shown on the Product Filter Field.
Arguments:
$placeholder string
the placeholder
Return:
string
the placeholder to use
woocommerce_product_search_avoid_redirect_canonical_loops
↑ Back to topThis filter determines whether the search engine will try to avoid redirect loops caused by URL transformations outside the scope of its influence. At WordPress 5.7.2 and WordPress 5.8 alpha, filter requests URLs can wrongly be transformed from uppercase URL-encoded characters to lowercase URL-encoded characters and redirected, causing infinite redirect loops.
Arguments:
$avoid boolean
whether to avoid redirect loops
Return:
boolean
whether to apply the search engine’s solution to avoid redirect loops
woocommerce_product_search_process_query_object_term_limit
↑ Back to topLimits the number of different terms that can be requested via filters.
Arguments:
$limit int
maximum number of terms per filter request, defaults to 100
Return:
int
number of terms
woocommerce_product_search_process_query_product_taxonomies
↑ Back to topThis filter is used to determine whether a product taxonomy will be processed during the search engine’s query processing routine.
Arguments:
$product_taxonomies string[]
product taxonomies$wp_query WP_Query
the query instance
Return:
string[]
product taxonomies to process
woocommerce_product_search_auto_toggle_filter_widgets
↑ Back to topThis filter determines whether filter widgets should be toggled automatically.
Arguments:
$toggle boolean
whether to toggle filter widgets automatically, default:true
Return:
boolean
whether to toggle filter widgets
woocommerce_product_search_cache_lifetime
↑ Back to topThis filter allows to modify the cache lifetime for stored results, the value is in seconds.
Arguments:
$lifetime int
the number of seconds
Return:
int
the number of seconds
woocommerce_product_search_compat
↑ Back to topThis filter allows to choose whether a compatibility resource will be loaded or not.
Arguments:
$load boolean
whether to load the compatibility resource$what string
either “plugin” or “theme” indicating whether the compatibility resources for a plugin or for a theme should be loaded$name string
the name of the plugin or theme for which the compatibility resources should be loaded
Return:
boolean
this filter must return true
if compatibility resources should be loaded for the given plugin or theme, false
otherwise
woocommerce_product_search_compat_woocommerce_brands_index
↑ Back to topThis filter allows to enable/disable indexing of brands related to products, integrating with the WooCommerce Brands extension.
Arguments:
$enable boolean
whether to index brands related to products, enabled by default
Return:
boolean
true if brands should be indexed, otherwise false
woocommerce_product_search_compat_woocommerce_product_vendors_index
↑ Back to topThis filter allows to enable/disable indexing of vendors related to products, integrating with the WooCommerce Product Vendors extension.
Arguments:
$enable boolean
whether to index vendors related to products, enabled by default
Return:
boolean
true if vendors should be indexed, otherwise false
woocommerce_product_search_ext_product_data_store
↑ Back to topWhether to use the extended product data store used to power back end and JSON product searches.
Arguments:
$load boolean
takes the default value from theWPS_EXT_PDS
constant
Return:
boolean
whether to load the data store
woocommerce_product_search_field_product_add_to_cart_html
↑ Back to topAllows to alter the HTML for the button that allows to add a product to the cart. Applies to the results presented for the live search field. Use with caution as malformed HTML will corrupt the structure of the results displayed.
Arguments:
$add_to_cart_html string
the HTML for the button$post_id
int
the product’s ID
Return:
string
the HTML for the button
woocommerce_product_search_field_product_description
↑ Back to topAllows to alter the description of a product. Applies to the results presented for the live search field. Use with caution as malformed HTML will corrupt the structure of the results displayed.
Arguments:
$description string
the description$post_id
int
the product’s ID
Return:
string
the description
woocommerce_product_search_field_product_price_html
↑ Back to topAllows to alter the HTML for the price displayed of a product. Applies to the results presented for the live search field. Use with caution as malformed HTML will corrupt the structure of the results displayed.
Arguments:
$price_html string
the HTML for the price$post_id
int
the product’s ID
Return:
string
the HTML for the price
woocommerce_product_search_field_product_title
↑ Back to topAllows to alter the title displayed for a product. Applies to the results presented for the live search field. Use with caution as malformed HTML will corrupt the structure of the results displayed.
Arguments:
$title string
the title$post_id
int
the product’s ID
Return:
string
the title
woocommerce_product_search_field_more_anchor_title
↑ Back to topAllows to alter the text displayed when there are more results in the Product Search Field. The translatable string "Search for more …"
is the default.
Arguments:
$text string
the title of the more link
Return:
string
the title of the more link
woocommerce_product_search_field_more_title
↑ Back to topAllows to alter the text displayed when there are more results in the Product Search Field. The translatable string "more …"
is the default.
Arguments:
$text string
the text shown in the more link
Return:
string
the text shown in the more link
woocommerce_product_search_filter_auto_append
↑ Back to topThis determines whether the Product Search Filter is automatically appended when its presence is not detected but filters are used.
Arguments:
$auto_append boolean
whether to append the filter automatically, default:true
Return:
boolean
whether to append the filter automatically
woocommerce_product_search_filter_heading_allowed_elements
↑ Back to topAllows to modify the allowed HTML elements in filter headings.
Arguments:
$tags array
the allowed HTML elements
Return:
array
the allowed HTML elements
woocommerce_product_search_filter_price_decimals
↑ Back to topThis filter allows to modify the number of decimals used for the price filter provided by the Product Filter – Price widget, the [woocommerce_product_filter_price]
shortcode and the equivalent API function.
Arguments:
$decimals int
number of decimals
Return:
int
number of decimals
woocommerce_product_search_service_min_max_price_adjust_decimals
↑ Back to topAllows to modify the number of decimals used to calculate minimum and maximum price limits used by the Product Filter – Price widget, the [woocommerce_product_filter_price]
shortcode and the equivalent API function.
Arguments:
$decimals int
number of decimals
Return:
int
number of decimals
woocommerce_product_search_service_min_max_price_adjust_for_display_decimals
↑ Back to topAllows to modify the number of decimals used to display the minimum and maximum price limits used by the Product Filter – Price widget, the [woocommerce_product_filter_price]
shortcode and the equivalent API function.
Arguments:
$decimals int
number of decimals
Return:
int
number of decimals
woocommerce_product_search_filter_price_prefix
↑ Back to topFilters the prefix displayed before the price filter is rendered.
Arguments:
$prefix string
the prefix
Return:
string
the prefix
woocommerce_product_search_filter_price_suffix
↑ Back to topFilters the suffix displayed after the price filter is rendered.
Arguments:
$suffix string
the suffix
Return:
string
the suffix
woocommerce_product_search_filter_product_loop_content
↑ Back to topFilters the content of the product loop.
Arguments:
$html string
the content
Return:
string
the content
woocommerce_product_search_filter_product_loop_prefix
↑ Back to topFilters the prefix displayed before the product loop.
Arguments:
$html string
the prefix
Return:
string
the prefix
woocommerce_product_search_filter_product_loop_suffix
↑ Back to topFilters the suffix displayed after the product loop.
Arguments:
$html string
the suffix
Return:
string
the suffix
woocommerce_product_search_filter_products_catalog_ordering
↑ Back to topFilters the HTML that displays the catalog ordering.
Arguments:
$html string
the catalog ordering HTML output
Return:
string
the catalog ordering HTML
woocommerce_product_search_filter_products_pagination
↑ Back to topFilters the HTML that displays the pagination.
Arguments:
$html string
the pagination HTML output
Return:
string
the pagination HTML
woocommerce_product_search_filter_products_prefix_close
↑ Back to topFilters the closing of the prefix that is rendered before product results are displayed.
Arguments:
$html string
the prefix closing
Return:
string
the prefix closing
woocommerce_product_search_filter_products_prefix_open
↑ Back to topFilters the opening of the prefix that is rendered before product results are displayed.
Arguments:
$html string
the prefix opening
Return:
string
the prefix opening
woocommerce_product_search_filter_products_suffix_close
↑ Back to topFilters the closing of the suffix that is rendered after product results are displayed.
Arguments:
$html string
the suffix closing
Return:
string
the suffix closing
woocommerce_product_search_filter_products_suffix_open
↑ Back to topFilters the opening of the suffix that is rendered after product results are displayed.
Arguments:
$html string
the suffix opening
Return:
string
the suffix opening
woocommerce_product_search_filter_products_result_count
↑ Back to topFilters the HTML that displays the results count.
Arguments:
$html string
the results count
Return:
string
the results count
woocommerce_product_search_filter_sale_prefix
↑ Back to topFilters the prefix displayed before the sale filter is rendered.
Arguments:
$prefix string
the prefix
Return:
string
the prefix
woocommerce_product_search_filter_sale_suffix
↑ Back to topFilters the suffix displayed after the sale filter is rendered.
Arguments:
$suffix string
the suffix
Return:
string
the suffix
woocommerce_product_search_filter_shortcode_products
↑ Back to topThis filters allows to determine whether the search engine should filter the standard WooCommerce [products]
shortcode.
The default behavior is determined via the value of the WPS_SHORTCODES_PRODUCTS_FILTER
constant. Its value is false
unless defined otherwise.
Arguments:
$filter boolean
whether to filter the shortcode
Return:
boolean
whether to filter the shortcode
woocommerce_product_search_filter_shortcode_products_query
↑ Back to topFilters the query arguments used to retrieve products.
Arguments:
$query_args array
the query parameters$atts array
the shortcode attributes$loop_name string
identifies the product filter loop
Return:
array
the query parameters
woocommerce_product_search_filter_stock_stock_counts
↑ Back to topThis filter allows to modify the stock counts used by the search engine’s stock filter to determine whether there are any products in stock, on backorder and out of stock. For the purpose of displaying a stock filter using the Product Filter – Stock widget, the [woocommerce_product_filter_stock]
shortcode or the equivalent API function, the search engine considers that products are available when the sum of instock
and onbackorder
is greater than zero.
Arguments:
$counts array
the stock counts indexed byinstock
,outofstock
andonbackorder
Return:
array
the stock counts
woocommerce_product_search_filter_stock_stock_counts_cache_expire
↑ Back to topThis filter allows to modify the time period in seconds until cached stock counts expire.
Arguments:
$expire int
seconds until cached stock counts expire
Return:
int
seconds until cached stock counts expire
woocommerce_product_search_filter_{$taxonomy}_args
↑ Back to topAllows to modify the arguments used to retrieve terms for the taxonomy.
Arguments:
$params array
the arguments used to retrieve taxonomy terms
Return:
array
the arguments to use
woocommerce_product_search_filter_{$taxonomy}_content
↑ Back to topFilters the content displayed for the taxonomy filter.
Arguments:
$content string
the content
Return:
string
the content
woocommerce_product_search_filter_{$taxonomy}_prefix
↑ Back to topFilters the prefix displayed before the taxonomy filter is rendered.
Arguments:
$prefix string
the prefix
Return:
string
the prefix
woocommerce_product_search_filter_{$taxonomy}_suffix
↑ Back to topFilters the suffix displayed after the taxonomy filter is rendered.
Arguments:
$suffix string
the suffix
Return:
string
the suffix
woocommerce_product_search_filter_terms
↑ Back to topThis filter determines whether term filters will be applied or not.
Arguments:
$filter boolean
whether to filter terms, default:true
Return:
boolean
whether to filter terms
woocommerce_product_search_filter_terms_always
↑ Back to topThis filter decides whether terms will be filtered always or only before the shop loop.
Arguments:
$filter boolean
whether to filter terms, default:false
Return:
boolean
whether to filter terms always
woocommerce_product_search_get_min_max_price
↑ Back to topThis filter allows to modify the minimum and maximum price used to delimit the values that can be used with the Product Filter – Price widget, the shortcode [woocommerce_product_filter_price]
and the equivalent woocommerce_product_search_filter_price()
API function.
Arguments:
$min_max
array
holds limits indexed by keys'min_price'
and'max_price'
Return:
array
limits
woocommerce_ product_search_get_terms_args_apply
↑ Back to topAllows to exit before the get_terms_args filter is processed.
Arguments:
$apply boolean
– whether to apply the search engine’s get_terms_args filter$args array
– arguments as supplied to the filter$taxonomies array
– taxonomies as supplied to the filter
Return:
boolean
whether to apply the filter
woocommerce_product_search_get_terms_args_process_terms
↑ Back to topThis filter determines whether to process terms within get_terms_args.
Arguments:
$process_terms boolean
whether to process terms$args array
arguments from get_terms_args$taxonomies array
involved taxonomies
Return:
boolean
whether to process terms
woocommerce_product_search_get_terms_args_process_terms_search
↑ Back to topThis filter determines whether to process terms based on the requested search within get_terms_args.
Arguments:
$process_terms boolean
whether to process terms$is_search_request boolean
whether this is a search request$args array
arguments from get_terms_args$taxonomies array
involved taxonomies
Return:
boolean
whether to process terms
woocommerce_product_search_get_terms_args_process_terms_taxonomies
↑ Back to topThis filter determines whether to process terms based on the requested terms within get_terms_args.
Arguments:
$process_terms boolean
whether to process terms$is_terms_request boolean
whether this is a request for terms$args array
arguments from get_terms_args$taxonomies array
involved taxonomies
Return:
boolean
whether to process terms
woocommerce_product_search_get_terms_args_stop_args
↑ Back to topAllows to set or modify the arguments used to abandon the get_terms_args filter before processing. When any of the arguments are found provided in the filter invocation’s arguments, processing will not occur.
Arguments:
$stop_args array
an array of strings identifying the stop args
Return:
array
the array of stop args
woocommerce_product_search_get_terms_filter_counts
↑ Back to topDetermines whether the term counts are adjusted based on current filter settings.
Arguments:
$adjust boolean
– whether to adjust the term counts$terms array
– found terms$taxonomies array
– taxonomies in context$args array
– get_terms() arguments$term_query WP_Term_Query
– term query object
Return:
boolean
whether to adjust the term counts
woocommerce_product_search_indexer_check_execution_limit
↑ Back to topWhether the indexer should try to avoid exceeding execution time limits.
Arguments:
$check_execution_limit boolean
whether to check and avoid exceeding the execution time limits
Return:
boolean
whether to check and avoid exceeding limits
woocommerce_product_search_indexer_check_memory_limit
↑ Back to topWhether the indexer should try to avoid exceeding memory limits.
Arguments:
$check_memory_limit boolean
whether to check and avoid exceeding the memory limits
Return:
boolean
whether to check and avoid exceeding limits
woocommerce_product_search_indexer_filter_content
↑ Back to topAllows to modify or add additional terms to content that is being indexed for a product.
Arguments:
$content string
the content that will be indexed$context string
the context for the content being indexed$post_id
int the ID of the product being indexed
Return:
string
the content that will be indexed
We provide an example implementation for this filter which is available as a plugin at https://github.com/itthinx/wps-indexer-filter-test – this example will add metadata based on the test_meta
key to the product’s content being indexed.
The following example will include product metadata for series, part number and manufacturer. The corresponding meta keys are held in the $fields
variable:
add_filter( Â Â Â 'woocommerce_product_search_indexer_filter_content', Â Â Â 'example_indexer_filter_content', Â Â Â 10, Â Â Â 3 ); function example_indexer_filter_content( $content, $context, $post_id ) { Â Â Â if ( $context === 'post_content' ) { Â Â Â Â Â Â Â $fields = array( 'series', 'part_number', 'manufacturer' ); Â Â Â Â Â Â Â $product = wc_get_product( $post_id ); Â Â Â Â Â Â Â $meta_values = array(); Â Â Â Â Â Â Â foreach ( $fields as $meta_key ) { Â Â Â Â Â Â Â Â Â Â Â $meta_value = $product->get_meta( $meta_key ); Â Â Â Â Â Â Â Â Â Â Â if ( !empty( $meta_value ) && is_string( $meta_value ) ) { Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â $meta_values[] = $meta_value; Â Â Â Â Â Â Â Â Â Â Â } Â Â Â Â Â Â Â } Â Â Â Â Â Â Â if ( count( $meta_values ) > 0 ) { Â Â Â Â Â Â Â Â Â Â Â $content .= ' ' . implode( ' ', $meta_values ); Â Â Â Â Â Â Â } Â Â Â } Â Â Â return $content; }
The woocommerce_product_search_indexer_filter_content
filter can be used together with desired product metadata to include any desired additional information for products. Once the products are again indexed, the search engine will retrieve results based on the added information. This also works with plugins such as Advanced Custom Fields who rely on WordPress’ metadata related to posts.
Please note that you need to re-index so the search engine will find the added data.
woocommerce_product_search_indexer_limit
↑ Back to topDetermines the processing limit per cycle. During each indexing cycle, the indexer will try to process up to $limit
entries.
Arguments:
$limit int
the maximum number of entries to process per cycle
Return:
int
the desired limit per cycle
woocommerce_product_search_indexer_object_term_term_ids
↑ Back to topThis filter determines the term IDs that are related to a particular product.
Arguments:
$term_ids int[]
the IDs of the terms related to the product$product WC_Product
the product
Return:
int[]
the IDs of the terms that are related to the product
woocommerce_product_search_like_within
↑ Back to topThis filters determines whether matches for search terms are sought within indexed tokens or not. By default, the filter will return false, only producing exact matches or partial matches that start with search terms. If it returns true, the processing time can increase substantially and have a negative impact on overall performance, although it will be lighter if appropriate caching is used.
Example – The following function can be used to enable searches within tokens. This function can be placed within a child theme’s functions.php or preferably encapsulated as a plugin – we have created this plugin (download) which you can install and activate so you won’t need to implement this yourself:
add_filter( 'woocommerce_product_search_like_within', 'enable_wps_search_like_within', 10, 3 ); function enable_wps_search_like_within( $enable, $object_type_ids, $search_terms ) { Â Â Â return true; }
Arguments:
$enable boolean
whether to search within indexed tokens, default is false$object_type_ids array
the type of objects considered to look for tokens$search_terms array
the search terms
Return:
boolean
whether to search within tokens
woocommerce_product_search_no_results
↑ Back to topModifies the text shown for the Product Search Field when there are no results.
Arguments:
$no_results string
the text shown for no results
Return:
string
the text shown for no results
woocommerce_product_search_placeholder
↑ Back to topModifies the placeholder shown on the Product Search Field.
Arguments:
$placeholder string
the placeholder
Return:
string
the placeholder to use
woocommerce_product_search_record_hit
↑ Back to topThis filter is used to decide whether a search query hit should be recorded.
Arguments:
$record boolean
whether to record the hit, default:true
$query string
the query string$count int
the number of results founds for the query string$filter_args array
additional information about the context
Return:
boolean
whether to record the hit
woocommerce_product_search_request_search_query
↑ Back to topThis filter allows to modify the search query that is received by the search engine in a request.
Arguments:
$search_query string
the search as provided in the request
Return:
string
the search to be handled by the search engine
woocommerce_product_search_selectize_css
↑ Back to topAllows to switch the CSS loaded for the dropdown style based on selectize. Determines which selectize stylesheet is loaded and takes one argument, ‘selectize’ by default.
Arguments:
$selectize_css string
the selectize CSS to load, allowed: “selectize” (default), “selectize.default”, “selectize.bootstrap2”, “selectize.bootstrap3” and “selectize.legacy”
Return:
string
the CSS to use
woocommerce_product_search_shorten_ellipsis
↑ Back to topWith this filter the ellipsis used for shortened content can be modified. This does not alter the content.
Arguments:
$ellipsis string
the ellipsis$content string
the content to shorten$what string
kind of content, “description” or “title”
Return:
string
the ellipsis to use
woocommerce_product_search_shutdown_remove_all_actions
↑ Back to topDuring filter requests, the search engine will minimize any interference from other extensions when shutdown hooks are executed. While this is enabled by default, this filter can be used to inhibit the search engine from doing so during filter requests (not recommended).
Arguments:
 $remove
boolean
whether to remove all shutdown actions
Return:
boolean
remove all shutdown actions
woocommerce_product_search_term_node_select_apply_padding
↑ Back to topThis applies when a term filter is rendered as a select. Whether to apply padding to a term rendered within a select.
Arguments:
$apply_padding boolean
whether to apply padding$term WP_Term
the term to render$depth int
the depth in the term hierarchy at which the term is located
Return:
boolean
whether to apply padding
woocommerce_product_search_term_node_select_padding
↑ Back to topThis applies when a term filter is rendered as a select. Determines the expanded padding string prepended to a term rendered as an option within the select.
Arguments:
$expanded_padding string
the full string that will prefix the term shown$term WP_Term
the term to render$depth int
the depth in the term hierarchy at which the term is located
Return:
string
the padding string
woocommerce_product_search_term_node_select_padding_step
↑ Back to topDetermines the step width in pixels used for padding (padding pixels = depth * step) – default is 8 – return value must be numeric and is converted to int.
Arguments:
$padding_step int
the padding step width, default: 8$term WP_Term
the term to render$depth int
the depth in the term hierarchy at which the term is located
Return:
int
the padding step
woocommerce_product_search_term_node_select_padding_string
↑ Back to topThis applies when a term filter is rendered as a select. Determines the string used to build the prepended padding when a term is rendered as an option within a select. This string is repeated multiple times depending on the depth at which the term is located within the hierarchy. The default string used can be overridden with this filter.
Arguments:
$padding string
the full string prepended$term WP_Term
the term to render$depth int
the depth in the term hierarchy at which the term is located
Return:
string
the padding string
woocommerce_product_search_term_node_select_render_count
↑ Back to topAllows to modify the output that displays the number of related products for a term. This filter is called when displaying counts on filter terms.
Arguments:
$object_count_display
string
the number of related objects (products) for the filter term; defaults to the string ” (n)” where n is the number of related objects$term
WP_Term
the term to render$depth int
the depth in the term hierarchy at which the term is located$object_count
int
the count (the n in the default string)
Return:
string
the desired output to display the object count for the term
woocommerce_product_search_term_walker_anchor_content
↑ Back to topAllows to modify the anchor content for a term rendered in a term filter.
Arguments:
$anchor_content string
current anchor content$object object
the data object$depth int
the depth of the item$args array
context arguments$current_object_id int
the ID of the current item
Return:
string
anchor content
woocommerce_product_search_term_walker_expand
↑ Back to topThis filter allows to modify the string used to render a term’s expander. The default is Font Awesome’s “plus” – the HTML entity reference 
.
Arguments:
$expander string
the current expander used$object object
the data object
Return:
string
the expander to use
woocommerce_product_search_term_walker_retract
↑ Back to topThis filter allows to modify the string used to render a term’s retractor. The default is Font Awesome’s “minus” – the HTML entity reference 
.
Arguments:
$retractor string
the current retractor used$object object
the data object
Return:
string
the retractor to use
woocommerce_product_search_filter_divi_shop
↑ Back to topThis filter is used to determine whether instances of the Divi Shop module should be filtered.
Arguments:
$filter boolean
whether instances of the Divi Shop module should be filtered. The default value is determined by the value of theWPS_DIVI_SHOP_FILTER
constant which istrue
by default.
Return:
boolean
whether to filter