boxcart.dev

Shortcodes & Blocks

BoxCart provides five shortcodes and corresponding Gutenberg blocks to embed every major store page into your WordPress site.

Overview

Each core store page — Products, Basket, Checkout, Account, and Mini Basket — has a dedicated shortcode and a matching Gutenberg block. You can use whichever method suits your workflow: shortcodes work in any editor (Classic Editor, page builders, widget areas, theme templates), while Gutenberg blocks offer a visual preview inside the block editor.

All shortcodes are registered in the BoxCart_Shortcodes class (includes/frontend/class-boxcart-shortcodes.php).

Tip

After creating your pages, remember to assign them in BoxCart → Settings → General under the Page Setup section so BoxCart knows which page serves each role.

Products Shortcode

The [boxcart_products] shortcode renders the full product catalogue, including grid/table view toggle, category filtering, search, and pagination.

[boxcart_products]

Attributes

AttributeTypeDefaultDescription
categorystring (slug)''Filter by category slug. Leave empty to show all categories.
limitintFrom settings (products_per_page)Number of products per page before pagination kicks in.
columnsint (2–4)From settings (products_per_row)Products per row on desktop in grid view.
show_filteryes / noFrom settings (show_category_filter)Show or hide the category filter dropdown.
show_searchyes / noFrom settings (show_search)Show or hide the product search box.
show_pillsyes / noFrom settings (show_category_pills)Show or hide category pill buttons above the product grid.
paginationload_more / numbered / noneload_morePagination style. load_more appends products via AJAX, numbered shows page numbers, none shows all products.

Example with attributes:

[boxcart_products category="bakery" limit="12" columns="3" show_filter="yes" pagination="numbered"]
Tip

When no attributes are specified, all values fall back to the settings configured in BoxCart → Settings → Styling. Use attributes only when you need to override the defaults for a specific page.

Basket Shortcode

The [boxcart_basket] shortcode renders the full shopping basket page, displaying all items the customer has added, quantities, line totals, and the overall order total.

[boxcart_basket]

This shortcode accepts no attributes. Place it on a dedicated page and assign that page as the Basket Page in BoxCart → Settings → General.

Checkout Shortcode

The [boxcart_checkout] shortcode renders the checkout page where customers enter their details, select a collection slot, choose a payment method, and place their order. It also handles the order confirmation display when a valid order token is present in the URL.

[boxcart_checkout]

This shortcode accepts no attributes. Place it on a dedicated page and assign that page as the Checkout Page in BoxCart → Settings → General.

Account Shortcode

The [boxcart_account] shortcode renders the customer account area. When a visitor is not logged in, it displays login and registration forms. When logged in, it shows one of several views based on the ?view= query parameter in the URL.

[boxcart_account]

Account Views

View ParameterPage Displayed
(none)Account dashboard
ordersOrder history
order (with ?id=)Single order view
editEdit details and change password

This shortcode accepts no attributes. The view is controlled entirely via URL query parameters.

Mini Basket Shortcode

The [boxcart_mini_basket] shortcode renders a compact basket button that can be placed in your site header, navigation menu, or widget area. Clicking the mini basket opens the sidecart panel.

[boxcart_mini_basket]

Attributes

AttributeTypeDefaultDescription
stylestringicon-textDisplay style. Options: icon-count (cart icon with item count badge), icon-text (cart icon with total price), text-only (text-only display).

Example with a style attribute:

[boxcart_mini_basket style="icon-text"]

Gutenberg Blocks

BoxCart registers five Gutenberg blocks that mirror the shortcodes. These blocks are available in the WordPress block editor (Gutenberg) and provide a visual preview of the store component directly within the editor.

Available Blocks

Block NameEquivalent ShortcodeDescription
BoxCart Products[boxcart_products]Product catalogue with all filtering and pagination options
BoxCart Basket[boxcart_basket]Shopping basket page
BoxCart Checkout[boxcart_checkout]Checkout and order confirmation page
BoxCart Account[boxcart_account]Customer account area
BoxCart Mini Basket[boxcart_mini_basket]Compact basket button for headers and navigation

Inserting a Block

  1. Open the block inserter

    In the WordPress block editor, click the + button in the toolbar or press / in an empty paragraph block.

  2. Search for BoxCart

    Type BoxCart in the search field. All five BoxCart blocks will appear in the results.

  3. Select and configure

    Click the desired block to insert it. For the Products and Mini Basket blocks, use the block sidebar panel to configure attributes (category, columns, pagination style, etc.) — these map directly to the shortcode attributes described above.

Tip

Blocks provide the same options as their shortcode counterparts. The Products block sidebar includes dropdowns and toggles for category, columns, filter visibility, search, pills, and pagination — matching the shortcode attributes exactly.

Shortcodes vs Blocks

Both shortcodes and Gutenberg blocks produce identical frontend output. The choice between them depends on your editor preference and site setup.

FeatureShortcodesGutenberg Blocks
Editor compatibilityAny editor (Classic, Gutenberg, page builders, widgets, theme templates)Gutenberg block editor only
Visual previewNo — displays as text in the editorYes — shows a visual placeholder in the editor
ConfigurationVia shortcode attributes typed manuallyVia the block sidebar panel with dropdowns and toggles
Frontend outputIdenticalIdentical
PHP templatesCan be used with do_shortcode() in theme filesNot directly usable in PHP templates
Widget areasSupported (e.g. mini basket in a sidebar widget)Supported in block-based widget areas (WordPress 5.8+)

Technical Notes

wpautop Handling

WordPress applies the wpautop filter to post content, which automatically wraps text in <p> tags and converts double line breaks to <br> tags. This can break the flex and grid layouts used by BoxCart shortcode output.

To prevent this, the BoxCart_Shortcodes class removes the wpautop filter at priority 9 (before do_shortcode runs at priority 11) and restores it at priority 12 after the shortcodes have been processed. This ensures that BoxCart output renders cleanly without unwanted <p> and <br> tags, while leaving wpautop intact for the rest of your content.

Tip

If you notice unexpected spacing or broken layouts on a BoxCart page, check whether another plugin is re-adding wpautop at a conflicting priority. BoxCart handles this automatically, but conflicts can occur with plugins that manipulate the same filter.