Discussing Shopify Functions development, deployment, and usage in Shopify apps.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Is it possible to receive more information about product using its gid , from the discount function at rust ?
The question really is about tokens and authorization
For example if I have request
{
"cart": {
"lines": [
{
"id": "gid://shopify/CartLine/0",
"merchandise":
{
"id": "gid://shopify/ProductVariant/0"
}
}
]
}
}
I want to give discount 20% only if price more more than $20 and $1 if it is less, is it possible to receive the price?
You could store that parameter as a line item property when it's added to the cart. You won't be able to filter for it directly via the Shopify API but if you store all the order data on your end you should be able to quickly filter the set as you need.
You can access any information in the Function's graphql schema via input queries. In the case of the product cost, you should actually reference the cart line in your input query. Something like this:
query Input {
cart {
lines {
cost {
subtotalAmount {
amount
}
}
}
}
}
Nick Wesselman | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog