1. Knowledge Base
  2. WooCommerce Product Table
  3. Developer Documentation

Overriding text strings, labels and messages in the product table

All text in WooCommerce Product Table is fully translatable in the usual way using the gettext functions provided in WordPress. A number of common translations are included in the plugin – see this article for details. You also may be using a translation plugin such as Weglot or WPML.

Regardless of which language is used on your site, you may need to modify some of the text items used in the product tables, and we provide several hooks for this purpose.

For example, you may wish to modify the label shown for the search box, or change the ‘Showing 1 of 10 products’ message below the table.

wc_product_table_language_defaults

This filter allows you to override the default values for various items of text used within the plugin.

The following example changes the search label to ‘Filter’, and also changes the “empty table” and “zero records” text strings.

add_filter( 'wc_product_table_language_defaults', function( $defaults ) {
    $defaults['search']       = 'Filter';
    $defaults['emptyTable']   = 'Sorry, no products currently available.';
    $defaults['zeroRecords']  = 'No products matched your search. Try something else.';
    return $defaults;
} );

The full list of language strings and their default values are:

Option Default Description
$defaults['info'] Showing _START_ to _END_ of _TOTAL_ products The totals message below the table. _START_, _END_ and _TOTAL_ are placeholders for the product totals which appear in the message.
$defaults['infoEmpty'] Showing 0 products The totals message when there are no products.
$defaults['infoFiltered'] (_MAX_ products in total) The message after the totals when searching/filtering. _MAX_ is the placeholder for the maximum number of products.
$defaults['lengthMenu'] Show _MENU_ products The text for the ‘Show X products’ page_length dropdown. _MENU_ is the placeholder for the actual length dropdown.
$defaults['emptyTable'] No matching products found. Message when no products are found when table is first loaded.
$defaults['zeroRecords'] No matching products found. Message when no products are found after searching/filtering.
$defaults['search'] Search: The label shown in front of the search box.
$defaults['searchPlaceholder'] The placeholder for the search box.
$defaults['paginate']['first'] First The first pagination button.
$defaults['paginate']['last'] Last The last pagination button.
$defaults['paginate']['next'] Next The next pagination button.
$defaults['paginate']['previous'] Previous The previous pagination button.
$defaults['filterBy'] Filter: The label for the search filters.
$defaults['thousands'] , The ‘thousands’ separator for numbers and prices (e.g. $1,000)
$defaults['decimal'] . The decimal point for numbers and prices (e.g. $2.99)
$defaults['resetButton'] Reset The reset_button text.
$defaults['multiCartButton'] Add Selected To Cart The cart button text for the multi selection (also see add_selected_button option.
$defaults['multiCartNoSelection'] Please select one or more products. The message when no products are selected.

wc_product_table_search_label

This filter is provided for convenience, and is the same as modifying $defaults['search']  when using the wc_product_table_language_defaults filter.

Sets the text label shown in front of the search box. Defaults to “Search:”. You can set this to an empty string ("") to hide the label.

add_filter( 'wc_product_table_search_label', function( $label ) {
    return "I'm Looking for:";
} );

wc_product_table_filter_label

This allows you to change the “Filter:” text label shown next to the dropdown search filters.

add_filter( 'wc_product_table_filter_label', function( $label ) {
    return "Search by:";
} );

wc_product_table_filter_heading_<filter>

Allows you to change the heading (i.e. the default option) for the drop-down search filters shown above the table. The default heading for each filter is the same as the column heading (e.g. “Categories”, “Tags”, etc), or the custom column heading if you’ve supplied one.

You will need to append the appropriate filter name when using this hook:

  • For the categories filter: wc_product_table_filter_heading_categories
  • For the tags filter: wc_product_table_filter_heading_tags
  • For an attribute filter, e.g. pa_color: wc_product_table_filter_heading_pa_color
  • For a custom taxonomy, e.g. shop_brand: wc_product_table_heading_shop_brand

This example will change the heading for the “Categories” filter to “Filter by category”:

add_filter( 'wc_product_table_filter_heading_categories', function( $heading ) {
    return "Filter by category";
} );

wc_product_table_reset_button

Allows you to change the text used for the Reset button link above the table.

add_filter( 'wc_product_table_reset_button', function( $label ) {
    return "Clear";
} );

wc_product_table_multi_cart_button

Allows you to change the text used for the multiple add to cart button button above the table. Default button text is “Add Selected To Cart”.

add_filter( 'wc_product_table_multi_cart_button', function( $label ) {
    return "Add Selected Products";
} );
Still need help?
If searching the knowledge base hasn't answered your question, please contact support.

Related Articles