Discussing Shopify Functions development, deployment, and usage in Shopify apps.
Hey Nick,
How come you can only get one cart line item attribute? Is there a way to get all attributes for the line item?
attribute(key: "_isProduct") {
value
}
Thanks!
Solved! Go to the solution
This is an accepted solution.
@paulsocal As a general rule, input queries will not allow you to fetch any unbounded list, for performance reasons. You could fetch more than one attribute via GraphQL aliases.
Can I hear more about your use case? Elsewhere we provide fields like `inAnyCollection` or `hasAnyTag` to allow checking for values in unbounded lists.
isProduct: attribute(key: "_isProduct") {
value
}
isSale: attribute(key: "_isSale") {
value
}
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
This is an accepted solution.
@paulsocal As a general rule, input queries will not allow you to fetch any unbounded list, for performance reasons. You could fetch more than one attribute via GraphQL aliases.
Can I hear more about your use case? Elsewhere we provide fields like `inAnyCollection` or `hasAnyTag` to allow checking for values in unbounded lists.
isProduct: attribute(key: "_isProduct") {
value
}
isSale: attribute(key: "_isSale") {
value
}
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
Ah I knew theres probably a GraphQL solution to this. Thanks!
The use case:
On the frontend, we hit an API for a third party feed of products that users can select to add to their order. So I created a generic product that is set to a $1,000,000 price tag. On the front end, the pricing parameter gets attached as a property along with other variables so within the function the price gets adjusted via a discount on the $1m.
For example if the product is $3000, I can calculate that the product will be discounted 99.7%
Since the product is never in my shopify inventory, I can't attach any tags or metafields.