Documentation

TwoFilter plugin documentation

Technical reference for configuring and using the TwoFilter WooCommerce plugin. This documentation is based on the current plugin behavior.

1. Installation and activation

  1. Install and activate the `TS Filters` plugin.
  2. On activation, the plugin generates JSON filter data and schedules a nightly rebuild at 02:00.
  3. Go to `WooCommerce -> TS Filters` to configure filter blocks.

The plugin stores filter definitions in the `ts_filters_config` option and uses those settings for rendering and querying.

2. Admin filter builder

In `WooCommerce -> TS Filters`, you can add and sort filter rows. Each row includes:

  • Title: label shown on the frontend.
  • Taxonomy: product taxonomy or special source (`ts_search`, `_price`).
  • Type: `checkbox`, `slider`, `range`, `search`.
  • Limit: initial number of items shown for checkbox lists.

Saving the builder also triggers `ts_generate_all_json()`.

3. Shortcodes

Available shortcodes:

  • [ts_filters]
  • [ts_search]
  • [ts_live_search]

[ts_filters]

Attributes:

  • product_cat: preselect category slugs (comma-separated)
  • target: CSS selector of the result container (default: .col-md-9)

[ts_search]

Attributes:

  • placeholder: input placeholder text
  • class: extra CSS class on the search input

[ts_live_search]

Attributes:

  • placeholder
  • class
  • limit: min 1, max 20

4. URL parameters and query behavior

The plugin reads filter state from URL parameters:

  • product_cat and pa_* for taxonomy filtering (comma-separated slugs)
  • _price or other slider/range keys as min-max
  • ts_search for text search

These parameters are merged into WooCommerce product queries through `pre_get_posts`, `woocommerce_shortcode_products_query`, and `woocommerce_product_query` hooks.

5. JSON generation and cron

The plugin generates JSON files in the plugin folder under woocommerce-cats/:

  • tax_{taxonomy}.json for checkbox filter trees
  • meta_{meta_key}.json for slider/range min-max data

Rebuild triggers:

  • Plugin activation
  • Saving filters in admin
  • Nightly cron event ts_filters_nightly_rebuild

6. Live search endpoint

Live search uses AJAX action ts_live_search and returns:

  • matching WooCommerce products (title, URL, price, thumbnail, categories)
  • matching product categories

Both logged-in and logged-out users are supported.

7. Troubleshooting

  • If filters are empty, check filter config and regenerate JSON data.
  • If slider values look wrong, verify meta keys and product meta values.
  • If AJAX updates fail, confirm result container selector in target.
  • If changes are not visible, clear page/plugin cache and browser cache.

Need implementation help? Contact the team.