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

Obtaining all attributes for a line item

Solved

Obtaining all attributes for a line item

paulsocal
Shopify Partner
3 0 0

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!

Accepted Solution (1)

Nick_Wesselman
Shopify Staff
171 43 73

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

View solution in original post

Replies 2 (2)

Nick_Wesselman
Shopify Staff
171 43 73

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

paulsocal
Shopify Partner
3 0 0

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.