bigcommerce / storefront-data-hooks

Hooks for React Storefront UI Components
MIT License
166 stars 36 forks source link

How do I add a product that doesn't have variants? #21

Closed ricokahler closed 3 years ago

ricokahler commented 3 years ago

Looking at the typescript types for useAddItem, it doesn't seem like there is a way to add items to the cart that don't have a variant.

How do I do this?

amckemie commented 3 years ago

@jivewise Can you help provide some insight on this question? Thanks!

jivewise commented 3 years ago

@ricokahler I believe the ItemBody declaration will need to be updated here: https://github.com/bigcommerce/storefront-data-hooks/blob/master/src/api/cart/index.ts#L17 to be optional.

I will work with @amckemie to make a PR for that soon, or you can feel free to do so if you have the time!

jorgemasta commented 3 years ago

The variantId should be optional.

If a product has modifiers, omit the variant_id and instead use the option_selections array to describe both the variant and the modifier selections Documentation

jorgemasta commented 3 years ago

It will be included in the next release