mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
add support for displaying taxes
Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
parent
2943168803
commit
894f133739
@ -26,6 +26,12 @@ const CheckoutSidebarView: FC = () => {
|
|||||||
currencyCode: data.currency.code,
|
currencyCode: data.currency.code,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
const { price: taxes } = usePrice(
|
||||||
|
data && {
|
||||||
|
amount: Number(data.taxes),
|
||||||
|
currencyCode: data.currency.code,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SidebarLayout
|
<SidebarLayout
|
||||||
@ -68,7 +74,7 @@ const CheckoutSidebarView: FC = () => {
|
|||||||
</li>
|
</li>
|
||||||
<li className="flex justify-between py-1">
|
<li className="flex justify-between py-1">
|
||||||
<span>Taxes</span>
|
<span>Taxes</span>
|
||||||
<span>Calculated at checkout</span>
|
<span>{data.taxes ? taxes : 'Calculated at checkout'}</span>
|
||||||
</li>
|
</li>
|
||||||
<li className="flex justify-between py-1">
|
<li className="flex justify-between py-1">
|
||||||
<span>Shipping</span>
|
<span>Shipping</span>
|
||||||
|
@ -81,6 +81,8 @@ export type Cart = {
|
|||||||
totalPrice: number
|
totalPrice: number
|
||||||
// Discounts that have been applied on the cart.
|
// Discounts that have been applied on the cart.
|
||||||
discounts?: Discount[]
|
discounts?: Discount[]
|
||||||
|
// The total for taxes
|
||||||
|
taxes?: number
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -203,8 +203,8 @@ export function normalizeProduct(productNode: CatalogItemProduct): Product {
|
|||||||
export function normalizeCart(cart: ReactionCart): Cart {
|
export function normalizeCart(cart: ReactionCart): Cart {
|
||||||
return {
|
return {
|
||||||
id: cart._id,
|
id: cart._id,
|
||||||
customerId: '',
|
customerId: cart.account?._id ?? '',
|
||||||
email: '',
|
email: cart.account?.emailRecords[0].address ?? '',
|
||||||
createdAt: cart.createdAt,
|
createdAt: cart.createdAt,
|
||||||
currency: {
|
currency: {
|
||||||
code: cart.checkout?.summary?.total?.currency.code ?? '',
|
code: cart.checkout?.summary?.total?.currency.code ?? '',
|
||||||
@ -218,6 +218,7 @@ export function normalizeCart(cart: ReactionCart): Cart {
|
|||||||
subtotalPrice: +(cart.checkout?.summary?.itemTotal?.amount ?? 0),
|
subtotalPrice: +(cart.checkout?.summary?.itemTotal?.amount ?? 0),
|
||||||
totalPrice: cart.checkout?.summary?.total?.amount ?? 0,
|
totalPrice: cart.checkout?.summary?.total?.amount ?? 0,
|
||||||
discounts: [],
|
discounts: [],
|
||||||
|
taxes: cart.checkout?.summary?.taxTotal?.amount,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user