More in Learn

Retrieving Price List Info from the Catalogue

Because price lists are associated with product variants in your catalogue, you can retrieve information about them via the Catalogue API.

In order to perform these operations, ensure that you have the proper authentication (if necessary) and user permissions.

Here’s an example of fetching detailed information for all English-language products in the catalogue, including price list information:

query {
catalogue(path: "/", language: "en") {
id
path
children {
id
name
path
... on Product {
variants {
sku
name
price

priceVariants {
identifier
name
price
currency

priceForEveryone {
identifier
price
startDate
endDate
}

priceFor(marketIdentifiers: ["students"]) {
identifier
price
startDate
endDate
}

priceList(identifier: "price-list-for-students") {
identifier
price
}
}
}
}
}
}
}

Let’s break this down …

priceVariants {
identifier
name
price
currency

priceForEveryone {
identifier
price
startDate
endDate
}

priceFor(marketIdentifiers: ["students"]) {
identifier
price
startDate
endDate
}

Within priceVariants, you can use priceForEveryone to return the best price from price lists that target all markets. If there are no active price lists targeting everyone, priceForEveryone will equal the default price. It’s also possible for priceForEveryone to be greater than the default price (for instance, if someone uses a price list to apply a markup or late fee).

If you need pricing information for specific markets, you can use priceFor and pass in one or more market identifiers. priceFor will return the lowest price for any of them.

Finally, you can fetch the price for a given price list with the priceList property by passing in the price list’s identifier:

priceList(identifier: "price-list-for-students") {
identifier
price
}

Retrieving a Single Price Variant

Instead of using priceVariants to retrieve an array of price variants, you can use priceVariant to retrieve a single price variant based on its identifier. If no such variant exists, its associated fields will be null.

query { 
catalogue(
path: "/"
language: "en"
) {
id
path
children {
...on Product {
variants {
priceVariant(identifier: "eur") { # returns one entry of price variants, or null
identifier
name
price
currency
}
}
}
}
}
}

Fetching the Product Variants Subject to a Price List

It’s also possible to fetch a price list and return the variants associated with it. The example below paginates the variants that are returned.

query {
priceList(identifier: "price-list-for-students") {
tenantId
identifier
name
modifierType
products (
language: "en"
after: "eyJfaWQiOiI2MWMzMTE5YWZjZDE1MDZmODdjYmQwOWMifQ=="
#first: 2
) {
pageInfo {
hasPreviousPage
hasNextPage
startCursor
endCursor
totalNodes
}
edges {
cursor
node {
id
type
name
variants {
sku
price
priceVariants {
identifier
name
currency
price
priceList (identifier: "price-list-for-students") {
startDate
endDate
identifier
price
}
}
}
}
}
}
}
}

For further details, please refer to the API docs accessible from the GraphQL playground for the Catalogue API (https://api.crystallize.com/your-tenant-identifier/catalogue).

People showing thumbs up

Need further help?

Join and ask our
slack community.

Join our slack community