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,
|
||||
}
|
||||
)
|
||||
const { price: taxes } = usePrice(
|
||||
data && {
|
||||
amount: Number(data.taxes),
|
||||
currencyCode: data.currency.code,
|
||||
}
|
||||
)
|
||||
|
||||
return (
|
||||
<SidebarLayout
|
||||
@ -68,7 +74,7 @@ const CheckoutSidebarView: FC = () => {
|
||||
</li>
|
||||
<li className="flex justify-between py-1">
|
||||
<span>Taxes</span>
|
||||
<span>Calculated at checkout</span>
|
||||
<span>{data.taxes ? taxes : 'Calculated at checkout'}</span>
|
||||
</li>
|
||||
<li className="flex justify-between py-1">
|
||||
<span>Shipping</span>
|
||||
|
@ -81,6 +81,8 @@ export type Cart = {
|
||||
totalPrice: number
|
||||
// Discounts that have been applied on the cart.
|
||||
discounts?: Discount[]
|
||||
// The total for taxes
|
||||
taxes?: number
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -203,8 +203,8 @@ export function normalizeProduct(productNode: CatalogItemProduct): Product {
|
||||
export function normalizeCart(cart: ReactionCart): Cart {
|
||||
return {
|
||||
id: cart._id,
|
||||
customerId: '',
|
||||
email: '',
|
||||
customerId: cart.account?._id ?? '',
|
||||
email: cart.account?.emailRecords[0].address ?? '',
|
||||
createdAt: cart.createdAt,
|
||||
currency: {
|
||||
code: cart.checkout?.summary?.total?.currency.code ?? '',
|
||||
@ -218,6 +218,7 @@ export function normalizeCart(cart: ReactionCart): Cart {
|
||||
subtotalPrice: +(cart.checkout?.summary?.itemTotal?.amount ?? 0),
|
||||
totalPrice: cart.checkout?.summary?.total?.amount ?? 0,
|
||||
discounts: [],
|
||||
taxes: cart.checkout?.summary?.taxTotal?.amount,
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user