Skip to content

Powered by Grav CMS + Helios Theme

Attributes

The store-wide vocabulary a product's specification table is written in.

The store-wide vocabulary a product's specification table is written in. The nine types, the validation messages and the value contract are on Products and catalog.

List product attributes

GET /api/v1/kahunacart/attributes Permission kahunacart.products.manage

Every attribute definition this store has, in display order, with its slug, label, type, option list, unit, group heading, filterable, filter_panel and show_on_product flags, translation overrides and how many products answer it, plus the vocabulary lists a create form needs: every type, the types that may be filtered on, and the two types that carry options. Attributes describe a product and never touch a price or an order line.

Get an attribute

GET /api/v1/kahunacart/attributes/{id} Permission kahunacart.products.manage

One attribute definition with its option list, translation overrides and product_count. Read product_count before changing the type or deleting it, because both are refused while products still answer it.

Parameters

Name Type Description
id required integer Attribute id

Create an attribute

POST /api/v1/kahunacart/attributes Permission kahunacart.products.manage

Define a store-wide attribute products can answer. A label and a type are required; the slug is derived from the label and de-duplicated. options is required for select and multiselect and ignored for the other seven types. unit is kept only on number. filterable is refused on textarea and url, which have nothing anybody would match on. filter_panel defaults to true and only matters while filterable is on: turn it off for an attribute with hundreds of values, which then stays linked from every product page and honoured in ?attr[...] URLs without adding a block of tick boxes to the filter panel. Values are set from the product side, through attributes on create_product or update_product.

Parameters

Name Type Description
label required string What a shopper reads on the specification table
slug optional string Derived from the label when omitted; used in filter URLs
type required string Decides what a value may be and how it is stored, filtered and rendered
One of: text, textarea, boolean, number, select, multiselect, date, url, color
options optional array of object Required for select and multiselect; ignored otherwise. Keys: `slug`, `label`
unit optional string or null Kept only on number, for example g or mm
group_label optional string or null Heading this attribute is grouped under
position optional integer Defaults to the end of the list
filterable optional boolean Honours ?attr[...] URLs, links every value from the product page and computes counts; refused on textarea and url
Default: false
filter_panel optional boolean Draws the facet in the filter panel; turn off for a filterable attribute with too many values to list
Default: true
show_on_product optional boolean Render it on the product page
Default: true
translations optional object Language code to overrides for label and group_label

Update an attribute

PATCH /api/v1/kahunacart/attributes/{id} Permission kahunacart.products.manage

Change an attribute definition. Only what is sent is written. Four rules to know: renaming the label never changes the slug, because the slug is in circulation in filter URLs, so send slug explicitly to change it; the type cannot change while products answer the attribute and answers 422 naming the count; retyping to a type that refuses filtering clears the flag rather than refusing the retype, so read filterable back off the response; and filter_panel is never cleared for you, because it is only about drawing the facet and is kept for the next time filtering goes back on.

Parameters

Name Type Description
id required integer Attribute id
label optional string
slug optional string
type optional string Refused with 422 while any product answers this attribute
One of: text, textarea, boolean, number, select, multiselect, date, url, color
options optional array of object Replaces the option list; removing an option in use is allowed, not refused. Keys: `slug`, `label`
unit optional string or null
group_label optional string or null
position optional integer
filterable optional boolean
filter_panel optional boolean Draws the facet in the filter panel; off leaves the links and the URLs working without one
show_on_product optional boolean
translations optional object

Reorder attributes

POST /api/v1/kahunacart/attributes/reorder Permission kahunacart.products.manage

Put the whole attribute list in the order the ids are given, and answer with how many moved and the reordered list. Ids naming nothing are ignored, and anything not listed keeps its place behind the ones that were. This is the display order of the specification table.

Parameters

Name Type Description
ids required array of integer Attribute ids in the order they should appear

Delete an attribute

DELETE /api/v1/kahunacart/attributes/{id} Permission kahunacart.products.manage

Delete an attribute definition, every value of it and its translations, and report how many products were carrying a value. Refused with 409 while products still answer it, naming the count; send force true to mean it and delete those values too. The same call with no force succeeds once the values are gone.

Parameters

Name Type Description
id required integer Attribute id
force optional boolean Delete the definition even though products answer it, removing their values
Default: false

Settable fields are slug, label, type, options, unit, group_label, position, filterable and show_on_product. Deleting a definition products still answer is a 409 naming the count; the same request with force succeeds and reports products_affected. Values live on the product, through the attributes map on a product body. See Attribute values over the API.