Skip to content

Gutenberg blocks

Three Gutenberg blocks for inserting storefront modules. Each block has an editor preview (server-side render) and configuration in the sidebar panel.

  • WordPress 6.0 or newer
  • Gutenberg block editor (not the classic editor)
  • The corresponding module active in Polski for WooCommerce settings

Polski for WooCommerce blocks can be found in the block inserter (the + button) in the Polski for WooCommerce category. You can also search for them by name by typing “Polski” or the module name.

Block name: polski/ajax-search

Inserts a search field with AJAX suggestions. Results appear in a dropdown while typing a phrase.

AttributeTypeDefaultDescription
placeholderstringSearch products...Placeholder text in the field
widthstring100%Field width
showIconbooltrueMagnifying glass icon
showCategoryboolfalseCategory filtering dropdown
limitnumber8Suggestion limit
minCharsnumber3Min. characters to search
stylestringdefaultStyle: default, rounded, flat

The block sidebar contains sections:

Search settings:

  • Placeholder text
  • Minimum number of characters
  • Results limit
  • Category filter (yes/no)

Appearance:

  • Field width
  • Style (default, rounded, flat)
  • Magnifying glass icon (yes/no)
  • Border (yes/no)
  • Shadow (yes/no)

Advanced:

  • Additional CSS classes
  • HTML anchor

Block registration example (internal implementation)

Section titled “Block registration example (internal implementation)”
register_block_type('polski/ajax-search', [
'api_version' => 3,
'editor_script' => 'polski-blocks-editor',
'editor_style' => 'polski-blocks-editor-style',
'style' => 'polski-blocks-style',
'render_callback' => [AjaxSearchBlock::class, 'render'],
'attributes' => [
'placeholder' => [
'type' => 'string',
'default' => __('Search products...', 'polski'),
],
'width' => [
'type' => 'string',
'default' => '100%',
],
'showIcon' => [
'type' => 'boolean',
'default' => true,
],
'showCategory' => [
'type' => 'boolean',
'default' => false,
],
'limit' => [
'type' => 'number',
'default' => 8,
],
],
]);
add_filter('polski/blocks/ajax_search/output', function (string $html, array $attributes): string {
// Modify block HTML
return $html;
}, 10, 2);

Block name: polski/ajax-filters

Inserts a set of AJAX filters for filtering the product list without page reload.

AttributeTypeDefaultDescription
filtersarray['category', 'price', 'stock']Active filters
stylestringexpandedStyle: expanded, compact, accordion
showCountbooltrueProduct counters
showResetbooltrueReset button
columnsnumber1Filter columns
collapsiblebooltrueCollapsible sections

Filter selection:

  • Checkboxes for each filter type
  • Drag & drop order sorting
  • Per-filter configuration (e.g. price ranges)

Appearance:

  • Display style (expanded, compact, accordion)
  • Number of columns
  • Counters (yes/no)
  • Reset button (yes/no)
  • Collapsed/expanded by default

Advanced:

  • AJAX / GET fallback mode
  • Additional CSS classes

The block automatically detects available filters based on product data:

FilterTypeDescription
categoryHierarchyProduct categories
priceRange sliderPrice range
stockCheckboxStock status
saleCheckboxOn sale only
brandListManufacturer/brand
pa_*List/SwatchProduct attributes
ratingStarsCustomer rating
add_filter('polski/blocks/ajax_filters/output', function (string $html, array $attributes): string {
return $html;
}, 10, 2);

The AJAX filters block works best in the shop page sidebar. In a block theme (FSE), add it to the Archive: Product template in the side column.

In classic themes, use the block in the Shop Sidebar widget area.

Block name: polski/product-slider

Inserts a product carousel with arrow navigation and optional pagination dots.

AttributeTypeDefaultDescription
typestringlatestType: related, sale, featured, bestsellers, latest, category, ids
limitnumber8Product limit
columnsnumber4Desktop columns
columnsTabletnumber2Tablet columns
columnsMobilenumber1Mobile columns
categorystringCategory slug
productIdsarray[]Product IDs
showArrowsbooltrueNavigation arrows
showDotsboolfalsePagination dots
autoplayboolfalseAutomatic scrolling
autoplaySpeednumber5000Pause between slides (ms)
gapstring16pxCard spacing
titlestringTitle
orderbystringdateSort by
orderstringDESCDirection

Product source:

  • Slider type (dropdown with options)
  • Category selection (for type=category)
  • Product selection (for type=ids) - search with auto-complete
  • Product limit
  • Sorting

Display:

  • Columns (desktop / tablet / mobile)
  • Gap
  • Arrows (yes/no)
  • Dots (yes/no)
  • Title

Animation:

  • Autoplay (yes/no)
  • Autoplay speed (slider 1000-10000 ms)
  • Pause on hover

The block renders a slider preview directly in the Gutenberg editor (server-side render). The preview shows real products from the database, allowing you to evaluate the appearance before publishing.

If the store has no products matching the selected type (e.g. no sale products), the block displays a placeholder with a message.

add_filter('polski/blocks/product_slider/output', function (string $html, array $attributes): string {
return $html;
}, 10, 2);
// Modify the product query
add_filter('polski/blocks/product_slider/query_args', function (array $args, array $attributes): array {
// Exclude products from the "hidden" category
$args['tax_query'][] = [
'taxonomy' => 'product_cat',
'field' => 'slug',
'terms' => 'hidden',
'operator' => 'NOT IN',
];
return $args;
}, 10, 2);

Polski for WooCommerce blocks work fully with block themes (Full Site Editing). They can be inserted in:

  • Page templates
  • Product archive templates
  • Template parts - header, footer, sidebar
  • Patterns

Each block generates CSS classes following the BEM convention. Additionally, blocks support native Gutenberg style settings:

  • Colors (text, background)
  • Typography (size, weight, font family)
  • Margins and paddings (spacing)
  • Border

Blocks do not appear in the inserter - make sure the corresponding module is active in WooCommerce > Polski > Storefront Modules. Blocks require activation of the corresponding module.

Block preview is empty - check that the store has products matching the selected type. An empty product database will not generate a preview.

Blocks do not work in Elementor - these blocks are designed for the Gutenberg editor. For Elementor, use shortcodes or dedicated Elementor widgets (available for AJAX search).

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

This page is for informational purposes only and does not constitute legal advice. Consult a lawyer before implementation. Polski for WooCommerce is open source software (GPLv2) provided without warranty.