mirror of
https://github.com/vercel/commerce.git
synced 2025-07-23 04:36:49 +00:00
🐛 bug: shippingLine undefined
:%s
This commit is contained in:
@@ -122,7 +122,7 @@ export type CartCheckout = {
|
|||||||
// Discounts that have been applied on the cart.
|
// Discounts that have been applied on the cart.
|
||||||
discounts?: Discount[]
|
discounts?: Discount[]
|
||||||
totalDiscount: number
|
totalDiscount: number
|
||||||
shippingLine: {
|
shippingLine?: {
|
||||||
priceWithTax: number
|
priceWithTax: number
|
||||||
shippingMethod: ShippingMethod
|
shippingMethod: ShippingMethod
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,7 @@ import { Product } from '@commerce/types/product'
|
|||||||
import { OperationContext } from '@commerce/api/operations'
|
import { OperationContext } from '@commerce/api/operations'
|
||||||
import { Provider, VendureConfig } from '../'
|
import { Provider, VendureConfig } from '../'
|
||||||
import { GetProductQuery } from '../../schema'
|
import { GetProductQuery } from '../../schema'
|
||||||
import { getProductQuery, getProductDetailQuery } from '../../utils/queries/get-product-query'
|
import { getProductQuery } from '../../utils/queries/get-product-query'
|
||||||
|
|
||||||
export default function getProductOperation({
|
export default function getProductOperation({
|
||||||
commerce,
|
commerce,
|
||||||
|
@@ -94,10 +94,10 @@ export function normalizeCartForCheckout(order: CartFragment): CartCheckout {
|
|||||||
countryCode: order.shippingAddress?.countryCode || '',
|
countryCode: order.shippingAddress?.countryCode || '',
|
||||||
phoneNumber: order.shippingAddress?.phoneNumber || '',
|
phoneNumber: order.shippingAddress?.phoneNumber || '',
|
||||||
},
|
},
|
||||||
shippingLine: {
|
shippingLine: order.shippingLines[0] ? {
|
||||||
priceWithTax: order.shippingLines[0].priceWithTax / 100,
|
priceWithTax: order.shippingLines[0]?.priceWithTax / 100,
|
||||||
shippingMethod: order.shippingLines[0].shippingMethod as ShippingMethod
|
shippingMethod: order.shippingLines[0]?.shippingMethod as ShippingMethod
|
||||||
},
|
}: undefined,
|
||||||
totalDiscount: order.discounts?.reduce((total, item) => total + item.amountWithTax, 0) / 100 || 0,
|
totalDiscount: order.discounts?.reduce((total, item) => total + item.amountWithTax, 0) / 100 || 0,
|
||||||
discounts: order.discounts.map(item => {
|
discounts: order.discounts.map(item => {
|
||||||
return { value: item.amountWithTax, description: item.description }
|
return { value: item.amountWithTax, description: item.description }
|
||||||
|
@@ -49,7 +49,7 @@ const CheckoutBill = ({ data }: CheckoutBillProps) => {
|
|||||||
</div>
|
</div>
|
||||||
<div className={s.line}>
|
<div className={s.line}>
|
||||||
Shipping
|
Shipping
|
||||||
<div className={s.shipping}>{data?.shippingLine.priceWithTax || 0} {data?.currency?.code}</div>
|
<div className={s.shipping}>{data?.shippingLine?.priceWithTax || 0} {data?.currency?.code}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={s.line}>
|
<div className={s.line}>
|
||||||
Estimated Total
|
Estimated Total
|
||||||
|
@@ -91,8 +91,10 @@ const CheckoutInfo = ({ onViewCart, currency = "" }: CheckoutInfoProps) => {
|
|||||||
}
|
}
|
||||||
return ''
|
return ''
|
||||||
case CheckoutStep.ShippingMethodInfo:
|
case CheckoutStep.ShippingMethodInfo:
|
||||||
console.log('oder here: ', order?.shippingLine)
|
if (order?.shippingLine) {
|
||||||
return `${order?.shippingLine.shippingMethod.name}, ${order?.shippingLine.priceWithTax ? `${order?.shippingLine.priceWithTax} ${currency}`: 'Free'}` || ''
|
return `${order?.shippingLine.shippingMethod.name}, ${order?.shippingLine.priceWithTax ? `${order?.shippingLine.priceWithTax} ${currency}` : 'Free'}` || ''
|
||||||
|
}
|
||||||
|
return ''
|
||||||
default:
|
default:
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user