mirror of
https://github.com/vercel/commerce.git
synced 2025-07-24 10:41:23 +00:00
♻️ enhan: normalize shippingLine price
:%s
This commit is contained in:
@@ -95,7 +95,7 @@ export function normalizeCartForCheckout(order: CartFragment): CartCheckout {
|
|||||||
phoneNumber: order.shippingAddress?.phoneNumber || '',
|
phoneNumber: order.shippingAddress?.phoneNumber || '',
|
||||||
},
|
},
|
||||||
shippingLine: {
|
shippingLine: {
|
||||||
priceWithTax: order.shippingLines[0].priceWithTax,
|
priceWithTax: order.shippingLines[0].priceWithTax / 100,
|
||||||
shippingMethod: order.shippingLines[0].shippingMethod as ShippingMethod
|
shippingMethod: order.shippingLines[0].shippingMethod as ShippingMethod
|
||||||
},
|
},
|
||||||
totalDiscount: order.discounts?.reduce((total, item) => total + item.amountWithTax, 0) / 100 || 0,
|
totalDiscount: order.discounts?.reduce((total, item) => total + item.amountWithTax, 0) / 100 || 0,
|
||||||
|
@@ -13,7 +13,6 @@ interface CheckoutBillProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const CheckoutBill = ({ data }: CheckoutBillProps) => {
|
const CheckoutBill = ({ data }: CheckoutBillProps) => {
|
||||||
// console.log("data here***: ", data)
|
|
||||||
return (
|
return (
|
||||||
<div className={s.warpper}>
|
<div className={s.warpper}>
|
||||||
<div className={s.title}>
|
<div className={s.title}>
|
||||||
@@ -40,22 +39,22 @@ const CheckoutBill = ({ data }: CheckoutBillProps) => {
|
|||||||
<div className={s.line}>
|
<div className={s.line}>
|
||||||
Discount {(data?.discounts?.length || 0) > 0 && `(${data?.discounts?.map(item => item.description).join(",")})`}
|
Discount {(data?.discounts?.length || 0) > 0 && `(${data?.discounts?.map(item => item.description).join(",")})`}
|
||||||
<div className={s.shipping}>
|
<div className={s.shipping}>
|
||||||
{data?.totalDiscount ? `${data?.totalDiscount} ${data?.currency?.code}` : "0"}
|
{data?.totalDiscount || 0} {data?.currency?.code}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={s.line}>
|
<div className={s.line}>
|
||||||
Subtotal
|
Subtotal
|
||||||
<div className={s.subTotal}>
|
<div className={s.subTotal}>
|
||||||
{data?.subtotalPrice ? `${data?.subtotalPrice} ${data?.currency?.code}` : "0"}
|
{data?.subtotalPrice || 0} {data?.currency?.code}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={s.line}>
|
<div className={s.line}>
|
||||||
Shipping
|
Shipping
|
||||||
<div className={s.shipping}>Free</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
|
||||||
<div className={s.total}>{data?.totalPrice ? `${data?.totalPrice} ${data?.currency?.code}` : "0"}</div>
|
<div className={s.total}>{data?.totalPrice || 0} {data?.currency?.code}</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@@ -119,21 +119,8 @@ const CheckoutInfo = ({ onViewCart, currency = "" }: CheckoutInfoProps) => {
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
|
||||||
// TODO: remove
|
|
||||||
// const { addProduct } = useAddProductToCart()
|
|
||||||
|
|
||||||
// const createOrder = () => {
|
|
||||||
// addProduct({ variantId: "92", quantity: 2 }, handleAddToCartCallback)
|
|
||||||
// }
|
|
||||||
// const handleAddToCartCallback = (isSuccess: boolean, message?: string) => {
|
|
||||||
// // console.log("after create order: ", isSuccess, message)
|
|
||||||
// }
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={s.warpper}>
|
<div className={s.warpper}>
|
||||||
{/* TODO: remove */}
|
|
||||||
{/* <ButtonCommon onClick={createOrder}>test create order</ButtonCommon> */}
|
|
||||||
doneSteps = {JSON.stringify(doneSteps)}
|
|
||||||
<div className={s.title}>
|
<div className={s.title}>
|
||||||
<Logo />
|
<Logo />
|
||||||
<div className={s.viewCart} onClick={onViewCart}>View cart</div>
|
<div className={s.viewCart} onClick={onViewCart}>View cart</div>
|
||||||
|
Reference in New Issue
Block a user