Skip to content

Gutenberg blocks for AJAX search, filters and product slider

Polski registers three dynamic blocks for its storefront modules. They sit in the Polski category of the block inserter, next to the plugin's legal and product data blocks. Each block is rendered by PHP on the storefront, so the page always shows the current products and module settings.

Block Name Module it needs Same output as
Polski AJAX Search polski/ajax-search AJAX Search [polski_ajax_search]
Polski AJAX Filters polski/ajax-filters AJAX Filters [polski_ajax_filters]
Polski Product Slider polski/product-slider Product Slider Carousel [polski_product_slider]

Switch the module on under Polski > Modules first. The block can be inserted while the module is off, but it then renders nothing on the storefront.

In the editor the block shows a labelled placeholder card, not a live preview. Check the result on the storefront.

A product search field with suggestions that load as the customer types. Sidebar panel Search settings:

Setting Attribute Default What it does
Placeholder placeholder empty Text inside the field
Search label searchLabel empty Label of the field
Results label resultsLabel empty Heading of the suggestion list
Show submit button showSubmitButton on Shows a button next to the field
Submit button text submitButtonText empty Text on the button
Minimum characters minChars 2 Characters typed before suggestions load, 1 to 6 in the editor
Results limit limit 6 Suggestions shown, 1 to 20 in the editor

The block passes only these values. Everything else, such as whether out-of-stock products appear, comes from the AJAX Search module settings.

A filter form for the product list. Sidebar panel Filter settings:

Setting Attribute Default
Title title empty
Show title showTitle on
Show categories showCategories on
Show brands showBrands on
Show price showPrice on
Show stock showStock on
Show sale showSale on
Show attributes showAttributes on

Each switch hides or shows one group of the form. Which product attributes are offered, and how categories are listed, follows the AJAX Filters module settings. Developers can change the filter presets with the polski/filters/preset and polski/filters/archive_preset filters.

A carousel of products. Sidebar panel Slider settings:

Setting Attribute Default What it does
Title title empty Heading above the slider
Source source Related products Related, upsell, sale or featured products
Product ID productId 0 The product whose related or upsell products are shown. 0 means the product of the current page.
Product limit limit 8 1 to 12 products
Show title showTitle on Shows the heading above the slider
Show price showPrice on Prices on the cards
Show add to cart showAddToCart on Add to cart buttons on the cards

Related and upsell products need a product. On a page that is not a product page, set Product ID, or the slider stays empty. Sale and featured products work anywhere.

Block themes, classic themes and Elementor

Section titled "Block themes, classic themes and Elementor"

The blocks work wherever the block editor does, including templates and template parts of a block theme. In a classic theme, or anywhere blocks are not available, use the shortcodes from the table above. Elementor has its own widgets for the same three features: AJAX Search, AJAX Filters and Product Slider.

The block shows nothing on the storefront The module behind it is off. Switch it on under Polski > Modules.

The product slider is empty The source is related or upsell products on a page without a product, or the product has none. Set Product ID or pick sale or featured products.

Report issues: github.com/wppoland/polski/issues