Adding support for default options and removing the one that we do not need

This commit is contained in:
okbel 2021-03-10 16:39:08 -03:00
parent 9669c426e0
commit a6cbd3d581
2 changed files with 5 additions and 2 deletions

View File

@ -39,7 +39,6 @@ const ProductView: FC<Props> = ({ product }) => {
})
}, [])
console.log(product.variants[0])
const variant = getVariant(product, choices)
const addToCart = async () => {

View File

@ -96,7 +96,11 @@ export function normalizeProduct(productNode: ShopifyProduct): Product {
price: money(priceRange?.minVariantPrice),
images: normalizeProductImages(images),
variants: variants ? normalizeProductVariants(variants) : [],
options: options ? options.map((o) => normalizeProductOption(o)) : [],
options: options
? options
.filter((o) => o.name !== 'Title') // By default Shopify adds a 'Title' name when there's only one option. We don't need it.
.map((o) => normalizeProductOption(o))
: [],
...rest,
}