Skip to content

Powered by Grav CMS + Helios Theme

Object templates

The small Twig templates that print an order, a product or a customer inside a notification.

An object template is the fragment a notification uses to print one object. Each slot has a default, and a store may override it. See Merchant notifications.

Read the object templates

GET /api/v1/kahunacart/object-templates Permission kahunacart.settings

The operator-editable formats — SKU, product and variant line titles, the order description a provider is handed, the order reference, the invoice file name and every order email's subject — each with its shipped default, the template it currently holds, the variables it may read and the sample its preview renders against. Pass slot to read one.

Parameters

Name Type Description
slot optional string One slot name, e.g. order_reference; omit for all of them

Save an object template

PUT /api/v1/kahunacart/object-templates Permission kahunacart.settings

Save the Twig template one slot renders. It is rendered in a sandbox against a fixed allowlist per slot, and a template that reads a variable outside that list, uses a tag or filter the sandbox does not allow, or fails on the slot's sample is refused with 422 and a message naming what was refused. An empty template restores the shipped default. A template formats a number the store has already allocated; it never generates one.

Parameters

Name Type Description
slot required string The slot name, e.g. pdf_filename or email_subject.order.shipped
template required string The Twig template; empty restores the shipped default

Preview an object template

POST /api/v1/kahunacart/object-templates/preview Permission kahunacart.settings

Render a template against the slot's sample or, with order_id, a real order, as an HTML fragment. Writes nothing.

The preview renders a template against the slot's sample object, or against a real order when order_id is sent, and writes nothing. A save is refused for the same reasons a preview fails, so the preview is the place to find out.