Shopify / js-buy-sdk

The JS Buy SDK is a lightweight library that allows you to build ecommerce into any website. It is based on Shopify's API and provides the ability to retrieve products and collections from your shop, add products to a cart, and checkout.
https://shopify.github.io/js-buy-sdk
MIT License
984 stars 259 forks source link

CartLineItemModel missing product title #313

Closed zombor closed 7 years ago

zombor commented 7 years ago

Looking to write a js app on top of shopify data for a store. The cart line item model documentation page has data documented which isn't available: http://shopify.github.io/js-buy-sdk/api/classes/CartLineItemModel.html

For example, it says there's title which seems to be missing:

shopify

It appears there's no actual way to get the product title for an item in a cart. Is there another way to get this data?

minasmart commented 7 years ago

cart line items are accessed through the getter lineItems on the cart object. attrs is internal implementation details.

The right way to get to the title attribute is cart.lineItems[0].title. If you're accessing it through attrs, you're getting the raw data from out APIs before it's been wrapped in a model.

pmdownie commented 7 years ago

I'm having a similar problem where the cart.lineItems[0].title value is undefined.

I'm passing the whole variant object through, but is there something else I should be passing the addLineItemToCart function?