Skip to content

Filters

Ivan edited this page Aug 18, 2022 · 15 revisions

WooCommerce only features.

Default woo filters extended by custom cool features.
Widget area for add filters to archive is 'Archive product'.
How to work with default woo filter widgets - there are a lot info in internet, for example official docs https://docs.woocommerce.com/document/woocommerce-widgets/.

Ajax 💭

Starter allows to enable ajax for sort/filter and pagination without plugins!
By default this feature disabled, can be enabled into customizer.

Where to enable ajax for sort/filter & pagination Filter: Ajax

How it works?

WordPress posts: everything handled via js assets\js\modules\wp\archive.js: by click requests related page (html) and injects into page.
WooCommerce products: everything handled via js assets\js\modules\woo\archive.js: by click requests related page (html) and injects into page.


Display types 📄〽️〰️

Fitlers has two custom selects for setup display type on front.

How to use

  1. Open widgets
  2. Add fitler (or expand existing) and setup display types for dekstop and mobile (by default used 'list' type)
Filter display types example Download this video example
Filter: display type

How it works?

Filter markup is customized in file inc\woocommerce\filter.php: added ACF Filter widget for dekstop/mobile display types and added required minimum markup for dropdown and collapse. Filter diplay type settings handled via css assets\scss\theme\woo\_filters.scss.


Color filter 🔴⚫🔵

How to use

  1. Open any attribute
  2. Add color
Color filter example Download this video example
Filter: color

How it works?

Filter markup is customized in file inc\woocommerce\filter.php: added ACF Color taxonomy and required minimum markup. Styled in file assets\scss\theme\woo\_filters.scss.


Code

  • ACF: Filter widget and Color taxonomy
  • js:
    • assets\js\modules\wp\archive.js
    • assets\js\modules\woo\archive.js
  • css: assets\scss\theme\woo\_filters.scss
  • tpl:
    • index.php - template for archive blog posts
    • woocommerce\archive-product.php - template for archive products
      • starter_archive_url - get archive canonical URL
      • <!-- filters layout --> - filters markup
    • woocommerce\content-widget-price-filter.php - ovverride default woo price filter tpl
  • logic:
    • inc\woocommerce\filter.php - customize filter layout; Change Price Filter Widget Increment; customize text in Sort select; Register Archive page widget area; customizer
Clone this wiki locally