bigcommerce / storefront-data-hooks

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

This product has options, variant ID is required #44

Closed zeekrey closed 3 years ago

zeekrey commented 3 years ago

Hey there,

I'm using the useAddItem() hook like this:

const addItem = useAddItem();
await addItem({
        productId: product.entityId,
        variantId: getCurrentVariant(product, choices)?.node.entityId!,
      });

The cart object looks like the following:

image

But when I try to use the checkout endpoints like https://api.bigcommerce.com/stores/wm5qmanqs7/v3/checkouts/${body.cartId}/ I receive the following answer:

'{"status":422,
"title":"Missing or incorrect required fields",
"type":"https://developer.bigcommerce.com/api-docs/getting-started/api-status-codes",
"errors":{"variant":"This product has options, variant ID is required"}}'
jorgemasta commented 3 years ago

I'm not sure if this a problem with this package since the cart creation looks ok.

Have you tried this in other env (postman, the api reference...)?

zeekrey commented 3 years ago

Yep, sorry. You're right. There is an issue with the customFields during checkout creation (https://github.com/bigcommerce/dev-docs/issues/1013). Should have checked the API first. Sorry 🥰