This commit is contained in:
okbel 2021-01-19 11:07:40 -03:00
parent d03df631ce
commit 017218c155
3 changed files with 10 additions and 6 deletions

View File

@ -15,13 +15,14 @@ const CartSidebarView: FC = () => {
const { price: subTotal } = usePrice(
data && {
amount: data.base_amount,
amount: data.subTotal,
currencyCode: data.currency?.code || 'USD',
}
)
const { price: total } = usePrice(
data && {
amount: data.cart_amount,
amount: data.total,
currencyCode: data.currency?.code || 'USD',
}
)

View File

@ -75,10 +75,12 @@ export function normalizeProduct(productNode: any): Product {
})
}
export function normalizeCart(cart: any): Cart {
return update(cart, {
export function normalizeCart(data: any): Cart {
return update(data, {
$auto: {
products: { $set: cart?.line_items?.physical_items?.map(itemsToProducts)}
products: { $set: data?.line_items?.physical_items?.map(itemsToProducts)},
subTotal: { $set: data.base_amount },
total: { $set: data.cart_amount }
},
$unset: ['created_time', 'coupons', 'line_items']
})

View File

@ -49,8 +49,9 @@ interface Cart extends Entity {
id: string | undefined
currency: { code: string }
taxIncluded?: boolean
totalAmmount: number | string
products: Pick<Product, 'id' | 'name' | 'prices'> & CartItem[]
subTotal: number | string
total: number | string
}
interface CartItem extends Entity {