Product Elements
WooCommerce product grid backed by a real WC_Query, with skins, five pagination modes and AJAX add-to-cart.
products-grid β WooCommerce product grid backed by a real WC_Query, with skins, five pagination modes and AJAX add-to-cart. It is a bespoke widget with a dedicated PHP renderer and editor components.
Identity#
| Field | Value |
|---|---|
| Widget name | Products Grid |
Node type (node.type) | products-grid |
| Palette group | WooCommerce |
| Implementation path | Bespoke (dedicated PHP element class + hand-written editor preview) |
| Available in the Elements panel | Yes |
| PHP element class | Jalpi_Element_Products_Grid |
| Editor canvas preview | ProductsGridPreview |
| Inspector Content tab | ProductsGridContent |
| Inspector Style tab | ProductsGridStyleTab |
| Needs the frontend script | Yes |
Purpose#
WooCommerce product grid backed by a real WC_Query, with skins, five pagination modes and AJAX add-to-cart.
Where it is registered#
Editor β WIDGET_REGISTRY in admin/editor/src/widgets/registry.ts with bespoke: true. The registry entry carries palette metadata and the seed defaultNode only; behaviour comes from the dedicated components.
Server β Jalpi_Element_Products_Grid is listed in Jalpi_Renderer::register_elements() and keyed by its type() return value, 'products-grid'.
Sanitizer β 'products-grid' is in the $allowed_types array of Jalpi_Sanitizer::sanitize_node(), and sanitize_content() has a dedicated case 'products-grid' branch.
Content schema (node.content)#
These are the keys that survive Jalpi_Sanitizer::sanitize_content(). Anything else sent by a client is discarded on save.
| Key | Type / allowed values | Default | Notes |
|---|---|---|---|
skin | 'classic' | 'cards' | 'minimal' | 'classic' | |
perPage | integer 1β100 | 8 | |
rows / useRows | integer 1β20 / boolean | 1 / false | When useRows is on, the page size is columns Γ rows |
equalHeight / masonry | boolean | true / false | |
source | latest | featured | sale | best-selling | top-rated | related | upsells | cross-sells | manual | 'latest' | |
categories / tags / brands | comma list of slugs or ids | '' | |
includeProducts / excludeProducts / includeIds / excludeIds | comma list of ids | '' | Digits only β they feed post__in / post__not_in |
stockStatus | any | instock | outofstock | onbackorder | 'any' | |
productStatus | publish | private | any | 'publish' | |
orderBy | date | title | price | popularity | rating | menu_order | rand | modified | 'date' | |
order | 'ASC' | 'DESC' | 'DESC' | |
offset | integer 0β10000 | 0 | |
showImage / showSaleBadge / showTitle / showRating / showPrice / showAddToCart | boolean | true | |
showExcerpt / showWishlist / showCompare / showQuickView / showCategories / showSku | boolean | false | |
secondaryImage / showQuantity / ignoreSticky | boolean | false | |
lazyLoad / ajaxAddToCart | boolean | true | |
buttonText | string | '' | |
pagination | none | numbers | prev-next | load-more | infinite | 'none' | |
loadMoreText / emptyMessage / emptyIcon | string | 'Load More' / 'No products found.' / 'π' |
Settings schema (node.settings)#
Keys accepted by Jalpi_Sanitizer::sanitize_settings() for this type, in addition to the shared keys every node has (cssId, cssClass, cssClasses, customCss, bgNormal/bgHover, overlayNormal/overlayHover, borderNormal/borderHover, and the st_* Split Animation group).
| Key | Type / allowed values | Default | Notes |
|---|---|---|---|
pg_cols_desktop / pg_cols_tablet / pg_cols_mobile | string | '4' / '2' / '1' | |
pg_col_gap / pg_row_gap | string px | '24' / '32' | |
pg_img_ratio / pg_img_fit / pg_img_hover / pg_img_size | string | '1/1' / 'cover' / 'zoom' / 'woocommerce_thumbnail' | |
pg_card_align / pg_card_radius | string | 'left' / '12' | |
pg_badge_pos / pg_btn_icon / pg_btn_icon_pos | string | 'top-left' / 'none' / 'before' |
Rendering#
Editor canvas β ProductsGridPreview in admin/editor/src/widgets/ProductsGridPreview.tsx. CanvasNode builds the inline preview style by layering Design-System token values, attached reusable classes, the node's own styles, then the active breakpoint's tabletStyles/mobileStyles.
Frontend β Jalpi_Element_Products_Grid::render() returns a single root tag scoped by the CSS selector .jalpi-el.jalpi-{id}, and pushes its rule set into the renderer with $renderer->add_css(). That single-root-tag contract is what lets the interaction engine inject data-jalpi-interact on any widget without per-widget code.
Behaviour β the element calls $renderer->set_needs_js('generic'), so assets/js/jalpi-frontend.js is enqueued. Each init*() function in that file guards on its own DOM selector, so nothing runs on pages that do not contain this widget.
Capabilities inherited from the node model#
Every node type β including this one β gets the following for free, because they operate on the tree rather than on any single widget:
- Style tab β typography, colours, background, border, shadow, spacing.
- Advanced tab β margin, padding, per-device visibility, CSS ID / class, reusable classes, per-element Custom CSS.
- Responsive overrides β
tabletStylesandmobileStylessibling maps, plushideOn. - Animation tab β the Interaction Engine (
node.interactions) and the Split Animation group (settings.st_*). - Design System links β
node.globalStyleReffor atomic tokens and composite typography/button presets. - Editor operations β copy, paste, duplicate, lock, drag-reorder, undo/redo, save as template, revision history.
Code Examples#
Minimal node JSON#
The shape this widget takes inside `page_data.sections`. Ids must be unique across the whole tree.
{
"id": "products_grid_a1b2c3d",
"type": "products-grid",
"content": {
"skin": "β¦",
"perPage": "β¦",
"rows": "β¦",
"equalHeight": "β¦",
"source": "β¦",
"categories": "β¦"
},
"styles": {}
}Notes#
Good to know
- Query building lives in
Jalpi_Woo_Query::build_args()and is filterable throughjalpi_products_grid_query_args. - Pagination and add-to-cart run through
admin-ajax.phpactionsjalpi_pg_pageandjalpi_pg_cart(Jalpi_Woo_Ajax), both nonce-checked with thejalpi_pgaction. - With WooCommerce inactive the grid still renders and paginates using
Jalpi_Woo_Placeholderdemo products.
Source
Files
includes/elements/class-jalpi-element-products-grid.php admin/editor/src/widgets/ProductsGridPreview.tsx admin/editor/src/components/panels/PropertiesPanel.tsx admin/editor/src/widgets/registry.ts includes/class-jalpi-sanitizer.php includes/class-jalpi-renderer.php assets/js/jalpi-frontend.js
Classes
Jalpi_Element_Products_Grid
Functions
render type
Last updated: November 2026