mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 12:24:18 +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 || '',
|
||||
},
|
||||
shippingLine: {
|
||||
priceWithTax: order.shippingLines[0].priceWithTax,
|
||||
priceWithTax: order.shippingLines[0].priceWithTax / 100,
|
||||
shippingMethod: order.shippingLines[0].shippingMethod as ShippingMethod
|
||||
},
|
||||
totalDiscount: order.discounts?.reduce((total, item) => total + item.amountWithTax, 0) / 100 || 0,
|
||||
|
@@ -13,7 +13,6 @@ interface CheckoutBillProps {
|
||||
}
|
||||
|
||||
const CheckoutBill = ({ data }: CheckoutBillProps) => {
|
||||
// console.log("data here***: ", data)
|
||||
return (
|
||||
<div className={s.warpper}>
|
||||
<div className={s.title}>
|
||||
@@ -40,22 +39,22 @@ const CheckoutBill = ({ data }: CheckoutBillProps) => {
|
||||
<div className={s.line}>
|
||||
Discount {(data?.discounts?.length || 0) > 0 && `(${data?.discounts?.map(item => item.description).join(",")})`}
|
||||
<div className={s.shipping}>
|
||||
{data?.totalDiscount ? `${data?.totalDiscount} ${data?.currency?.code}` : "0"}
|
||||
{data?.totalDiscount || 0} {data?.currency?.code}
|
||||
</div>
|
||||
</div>
|
||||
<div className={s.line}>
|
||||
Subtotal
|
||||
<div className={s.subTotal}>
|
||||
{data?.subtotalPrice ? `${data?.subtotalPrice} ${data?.currency?.code}` : "0"}
|
||||
{data?.subtotalPrice || 0} {data?.currency?.code}
|
||||
</div>
|
||||
</div>
|
||||
<div className={s.line}>
|
||||
Shipping
|
||||
<div className={s.shipping}>Free</div>
|
||||
<div className={s.shipping}>{data?.shippingLine.priceWithTax || 0} {data?.currency?.code}</div>
|
||||
</div>
|
||||
<div className={s.line}>
|
||||
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>
|
||||
|
@@ -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 (
|
||||
<div className={s.warpper}>
|
||||
{/* TODO: remove */}
|
||||
{/* <ButtonCommon onClick={createOrder}>test create order</ButtonCommon> */}
|
||||
doneSteps = {JSON.stringify(doneSteps)}
|
||||
<div className={s.title}>
|
||||
<Logo />
|
||||
<div className={s.viewCart} onClick={onViewCart}>View cart</div>
|
||||
|
Reference in New Issue
Block a user