Single source of truth for Birkly CMS documentation

Template functions registered by the Commerce plugin when active. Use them in client-site HTML for cart badges, buy links, and “from €X” pricing.

In short: With Commerce active you can use {commerce_cart_count}, {commerce_cart_url}, {commerce_buy_url}, {commerce_add_to_cart}, and {commerce_price_from}. For multi-SKU products, pass the variant sub-entry id/slug. Combine with normal loops and sub-collection syntax (of 'products'.current).

Video (follow-along): optional (P3) — add-to-cart flow

Beginner

Cart badge

<a href="/cart.html">Cart ({commerce_cart_count})</a>

Buy button on a product detail page

<a href="{commerce_buy_url slug my_products 1}">Buy now</a>
  • First argument: entry id or slug (variant sub-entry for options)
  • Second: collection slug
  • Third: quantity (optional, default 1)

Lowest price on a product detail page

On a detail URL (?collection=products&slug=…), slug resolves to the current entry:

<p>€{commerce_price_from slug products}</p>

Or pass the commerce field directly (variants, custom field slugs):

<p>€{commerce_price_from {'commerce'}}</p>
<p>€{commerce_price_from variant.commerce}</p>

The tag returns a number with a dot decimal (for example 6.50). Add your currency symbol and locale formatting in HTML/CSS.

Variants (sub-collection)

On a product detail page (URL has ?collection=products&slug=…):

{for each entry in 'variants' of 'products'.current ordered by order}
  <div>
    <h3>{title}</h3>
    <a href="{commerce_buy_url slug products 1}">Buy</a>
  </div>
{endfor}

Use the variant’s own slug/id in commerce_buy_url when that row is the sellable unit.

Advanced Users

For developers & AI

FunctionSignatureReturns
commerce_cart_countnoneSession cart item count
commerce_cart_urlnoneCart URL
commerce_buy_urlentry_id, collection_slug?, qty?Checkout / add URL
commerce_add_to_cartsame as buy_urlAlias
commerce_price_fromentry_id, collection_slug or commerce field valueLowest purchase-option price (catalog lookup or field array). Empty when unknown.

Registration: register_template_function() in Commerce plugin.php; omitted when inactive. See Plugin language extensions.

Do not invent {for each variant in sub_entries variants} — use of 'collection'.current / explicit slug.

Affiliate: Append ?ref=partner_id on site URLs when using affiliate rules.

Full page recipes: Storefront patterns.