Skip to main content

getCategories

The listing of products will always occur in the context of a store. As explained in our common flows page, a store will be selected first before products are displayed.

You can pass in the store's ID if you know it or its slug.

NameTypeDescription
fulfillmentDatetimeutc_timestampDate & time of fulfillment for the cart
fulfillmentTypeFulfillmentTypeCart's fulfillment type
storeIduuidCurrent store ID
storeSlugStringCurrent store slug - use if you do not yet know the store ID

Query

query getCategories(
$fulfillmentDatetime: utc_timestamp,
$fulfillmentType: FulfillmentType,
$storeId: uuid,
$storeSlug: String
) {
getCategories(
fulfillmentDatetime: $fulfillmentDatetime,
fulfillmentType: $fulfillmentType,
storeId: $storeId,
storeSlug: $storeSlug
) {
id
name
products {
categoryId
defaultVariantId
description
id
image {
original
standard
thumb
}
inStock
limit
maxPrice {
basePrice
}
minPrice {
basePrice
}
name
quickAddAllowed
restrictions {
alcoholic
}
slug
}
slug
}
}

Variables

{
"fulfillmentDatetime": utc_timestamp,
"fulfillmentType": "DELIVERY",
"storeId": uuid,
"storeSlug": "abc123"
}

Response

{
"data": {
"getCategories": [
{
"id": uuid,
"name": "xyz789",
"products": [ProductAggregateStoreView],
"slug": "abc123"
}
]
}
}

Field explanations:

On success, the above will return an array of products. A common request will then be to display these in a list like:

  • name: Product name
  • description: Product description
  • image: Product images in 3 different sizes. The original is the original resolution, the standard is 512x512, and the thumb is 64x64
  • inStock: Boolean stating whether the product is in stock or not
  • limit: Integer stating the max quantity that may be ordered. Null if there is no limit.
  • maxPrice: Decimal giving the price of the most expensive variant + required modifier price
  • minPrice: Decimal giving the price of the cheapest variant + required modifier price
  • quickAddAllowed: Boolean stating whether the product may be "quick added" (i.e. no need to show a product modal first). This will be true if there are no variants or required modifiers.
  • restrictions: Map of any restrictions that apply to the product (currently only one is available: alcoholic, which states whether the product contains alcohol or not)
  • slug: String identifier, can be used to generate links to the product

Products are returned grouped underneath their belonging categories in the arrangement specified in Controls.