storefront-api-examples icon indicating copy to clipboard operation
storefront-api-examples copied to clipboard

react-graphql-client: Error message when adding product to cart

Open ryangrunest opened this issue 5 years ago • 5 comments

Currently, there's an error message when adding a product to the cart: App.js:136 Uncaught ReferenceError: client is not defined

To fix this issue, in the addVariantToCart function within App.js, add the following: const client = this.props.client; and change each this.props.client to client.

ryangrunest avatar Feb 07 '20 19:02 ryangrunest

I've made the changes on a local branch, but I don't have rights to push branches up for this repository.

ryangrunest avatar Feb 07 '20 20:02 ryangrunest

@ryangrunest you can fork the repo and then do a PR from there

swalkinshaw avatar Feb 07 '20 20:02 swalkinshaw

Pull Request: https://github.com/Shopify/storefront-api-examples/pull/110

ryangrunest avatar Feb 07 '20 20:02 ryangrunest

To test this issue, I connected to my storefront within src/index.js, and attempted adding a product to the cart.

ryangrunest avatar Feb 07 '20 20:02 ryangrunest

@swalkinshaw how can i update the existing cart lineitem i can find shopify doc to increase the quantity of product that already in cart Ref: https://shopify.dev/custom-storefronts/cart#increase-an-items-quantity

but i want to add another product in the same cart by using cart id i can see using checkout craete we can use checkoutLineItemsReplace to remove the existing lineitem and replace with new lineitem as like is possible in cart?

Pls reply

mahaboobkhan29 avatar Jan 11 '22 13:01 mahaboobkhan29