thetrevorharmon / gatsby-theme-shopify-manager

The easiest way to start a Shopify shop on Gatsby.
https://gatsby-theme-shopify-manager.netlify.app/
MIT License
121 stars 11 forks source link

Feature Request: `useUpdateItem()` #58

Open beamercola opened 4 years ago

beamercola commented 4 years ago

updateQuantity is nice but I need to be able to update customAttributes

beamercola commented 4 years ago

I was making a PR, but I realized there's a "fundamental" problem for me in here. In the actions like updateItemQuantity orremoveItemFromCart - they expect a variantId as the parameter, and it looks for a cart item with that variant with getLineItem.

But in the case of using customAttributes it's possible to have two separate variants in the cart. I believe this reverse lookup shouldn't be done, and suggest passing the lineItemId which we have anyways.

I've done this in a branch on mine and it seems to be working well

Thoughts?

thetrevorharmon commented 4 years ago

Thank you for this! I have done very little with custom attributes but I knew that my solution was probably lacking 😄 I think what you're proposing makes sense. Are you saying that we should change the existing API or add a new API called useUpdateItem?

In my mind, it makes sense to keep the API the way it exists and then add another hook to help with this.

beamercola commented 4 years ago

@thetrevorharmon Agreed, I'll send a PR as soon as i get around to cleaning it up.