How do I capture Cart Line Item Properties using the Storefront API?

Solved
WadeA
Tourist
4 1 0

I am working on a headless redesign of a client's store. 


The current Liquid Cart Form is capturing custom data using line_item.properties . These properties get displayed on both the cart screen and the checkout page

I do not see line_item.properties listed for the Cart or Checkout objects in the Storefront API. However both of these objects allow adding custom attributes to Checkout and Cart line items. 

Are custom attributes the Storefront API-way of capturing line_item properties?

I built a page that captured custom attributes in the cart, and those attributes are viewable with the Order object in the Shopify Admin. 


However I did not see the custom attributes displayed on the Checkout page, but  line_item.properties do appear to be displayed on the Checkout page. 

Is there a way to make custom attributes appear on the Checkout page, without the store being on the Plus plan and having a custom checkout template?

 

Thank You

0 Likes
WadeA
Tourist
4 1 0

After working on my test app some more, it seems like I misread the API docs and the custom attributes are applied to the cart as a whole and not the individual cart line items. I was hopping to find a way to attach custom information to each item in the cart, much like you can do with custom properties in the liquid cart. The example return data is showing custom attributes for each line items. So I must be writing the mutation wrong.

0 Likes
WadeA
Tourist
4 1 0

This is an accepted solution.

I was adding my  attributes to the Cart and not the Cart Line Items. Once I added attributes to the Cart Lines, they showed up on the checkout page underneath the Product Variant name

0 Likes