Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

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

Can I get parameters of product at shopify function?

Can I get parameters of product at shopify function?

AndreyZienko
Shopify Partner
13 0 3

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? 


Replies 2 (2)

Neyor_expert
Tourist
7 0 1

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.

Kabir

Nick_Wesselman
Shopify Staff
171 43 73

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