mirror of
https://github.com/vercel/commerce.git
synced 2025-07-26 19:51:23 +00:00
viewed prodyct
This commit is contained in:
@@ -36,6 +36,7 @@ export default function getProductOperation({
|
||||
})),
|
||||
variants: product.variants.map((v) => ({
|
||||
id: v.id,
|
||||
name:v.name,
|
||||
options: v.options.map((o) => ({
|
||||
// This __typename property is required in order for the correct
|
||||
// variant selection to work, see `components/product/helpers.ts`
|
||||
|
2
framework/vendure/schema.d.ts
vendored
2
framework/vendure/schema.d.ts
vendored
@@ -3303,7 +3303,7 @@ export type GetProductQuery = { __typename?: 'Query' } & {
|
||||
variants: Array<
|
||||
{ __typename?: 'ProductVariant' } & Pick<
|
||||
ProductVariant,
|
||||
'id' | 'priceWithTax' | 'currencyCode' | 'price'
|
||||
'id' | 'priceWithTax' | 'currencyCode' | 'price' | "name"
|
||||
> & {
|
||||
options: Array<
|
||||
{ __typename?: 'ProductOption' } & Pick<
|
||||
|
@@ -1,5 +1,5 @@
|
||||
import { Cart } from '@commerce/types/cart'
|
||||
import { ProductCard } from '@commerce/types/product'
|
||||
import { ProductCard, Product } from '@commerce/types/product'
|
||||
import { CartFragment, SearchResultFragment } from '../schema'
|
||||
|
||||
export function normalizeSearchResult(item: SearchResultFragment): ProductCard {
|
||||
@@ -57,3 +57,18 @@ export function normalizeCart(order: CartFragment): Cart {
|
||||
})),
|
||||
}
|
||||
}
|
||||
|
||||
export function normalizeProductCard(product: Product): ProductCard {
|
||||
return {
|
||||
id: product.id,
|
||||
name: product.name,
|
||||
slug: product.slug,
|
||||
imageSrc: product.images[0].url,
|
||||
price: product.price,
|
||||
currencyCode: product.currencyCode,
|
||||
productVariantId: product.variants?.[0].id.toString(),
|
||||
productVariantName:product.variants?.[0].name,
|
||||
facetValueIds: product.facetValueIds,
|
||||
collectionIds: product.collectionIds,
|
||||
}
|
||||
}
|
@@ -12,6 +12,7 @@ export const getProductQuery = /* GraphQL */ `
|
||||
}
|
||||
variants {
|
||||
id
|
||||
name
|
||||
priceWithTax
|
||||
currencyCode
|
||||
options {
|
||||
|
Reference in New Issue
Block a user