Free cookie consent management tool by TermsFeed Generator
All Products & Integrations

jalpi page builder docs

WooCommerce Overview

The three shop widgets, their query layer, AJAX endpoints and graceful degradation without WooCommerce.

Jalpi CoreDeveloper
3 min read Β· November 2026

Three widgets run real WooCommerce queries server-side. They are bespoke rather than schema-driven precisely because a WC_Query and AJAX pagination cannot be expressed as a field schema.

The three widgets#

WidgetElement classQuery layerEditor preview
Products GridJalpi_Element_Products_GridJalpi_Woo_QueryProductsGridPreview
Product CategoriesJalpi_Element_Product_CategoriesJalpi_Woo_TermsProductCategoriesPreview
Single ProductJalpi_Element_Single_ProductWooCommerce template tagsSingleProductPreview

The query layer#

Jalpi_Woo_Query::build_args( $content, $limit, $page ) translates widget content into WP_Query arguments and returns them through the jalpi_products_grid_query_args filter. It handles nine source values β€” latest, featured, sale, best-selling, top-rated, related, upsells, cross-sells, manual β€” plus taxonomy filters, include/exclude id lists, stock status, ordering and offset.

Three private helpers do the input hardening: ids() (digits only), slugs() (slug or numeric id) and contextual_ids() (resolves related, upsells and cross-sells against the current product).

Jalpi_Woo_Terms::build_args() does the same for product_cat, filtered through jalpi_product_categories_args.

AJAX#

Jalpi_Woo_Ajax registers four handlers β€” two actions, each for logged-in and anonymous visitors:

ActionPurposeParameters
jalpi_pg_pageReturns one page of product-card HTMLnonce, post, node, page
jalpi_pg_cartAdds a product to the cartnonce, product id, quantity

Two design decisions are worth copying:

  1. The query never travels over the wire. Only post, node and page are sent; the handler loads the saved node from the database and rebuilds the query from it, so a client cannot craft an arbitrary product query.
  2. The card markup has one implementation. Rather than duplicating it, render_card_via_element() uses Closure::bind() to call the element’s private render_card() method, so AJAX pages and the server-rendered first page can never drift apart.

Access control: the post must be published, or the user must pass read_post. jalpi_pg_cart self-guards on WooCommerce being loaded and runs the core woocommerce_add_to_cart_validation filter.

Without WooCommerce#

Jalpi_Woo_Ajax::instance() is registered unconditionally so the grid still paginates even with WooCommerce inactive. Two placeholder classes stand in for the real objects:

  • Jalpi_Woo_Placeholder β€” implements the WC_Product surface the card renderer uses (get_name(), get_price_html(), get_sku(), is_on_sale(), get_average_rating(), and so on).
  • Jalpi_Woo_Term_Placeholder β€” the same idea for product_cat terms.

The editor also receives hasWoo in jalpiEditorConfig, so the inspector hides shop-only controls rather than offering links that cannot work.

Storefront theming#

Jalpi_Woo::init_frontend() runs when the class exists and adds a jalpi-kit-{id} body class from the jalpi_active_kit option. All kit-specific WooCommerce styling is scoped to that class, which is why importing a light kit over a dark one does not leave the two fighting.

It also provides a cart-count fragment and a small inline sync script so the header cart badge updates after an AJAX add-to-cart.

Source

Files

includes/class-jalpi-woo.php includes/class-jalpi-woo-query.php includes/class-jalpi-woo-terms.php includes/class-jalpi-woo-ajax.php includes/elements/class-jalpi-element-products-grid.php includes/elements/class-jalpi-element-product-categories.php includes/elements/class-jalpi-element-single-product.php admin/editor/src/widgets/ProductsGridPreview.tsx

Classes

Jalpi_Woo Jalpi_Woo_Query Jalpi_Woo_Terms Jalpi_Woo_Ajax Jalpi_Woo_Placeholder Jalpi_Woo_Term_Placeholder Jalpi_Element_Products_Grid

Functions

build_args run max_pages handle_page handle_cart init_frontend is_active cart_count