totalQuantity

This commit is contained in:
Kristian Duda 2024-06-28 22:07:06 +02:00
parent 6bbe1668e0
commit b18c017fff
2 changed files with 9 additions and 5 deletions

View File

@ -44,25 +44,26 @@ const reshapeCartItems = (lines: PayloadCart['lines']): CartItem[] => {
}; };
const reshapeCart = (cart: PayloadCart): Cart => { const reshapeCart = (cart: PayloadCart): Cart => {
const currencyCode = cart.currencyCode!;
return { return {
id: cart.id, id: cart.id,
checkoutUrl: '/api/checkout', checkoutUrl: '/api/checkout',
cost: { cost: {
totalAmount: { totalAmount: {
currencyCode: 'EUR', currencyCode,
amount: cart.totalAmount?.toString()! amount: cart.totalAmount?.toString()!
}, },
totalTaxAmount: { totalTaxAmount: {
currencyCode: 'EUR', currencyCode,
amount: '0.0' amount: cart.totalTaxAmount?.toString()!
}, },
subtotalAmount: { subtotalAmount: {
currencyCode: 'EUR', currencyCode,
amount: '0.0' amount: '0.0'
} }
}, },
lines: reshapeCartItems(cart.lines), lines: reshapeCartItems(cart.lines),
totalQuantity: 0 totalQuantity: cart.totalQuantity ?? 0
}; };
}; };

View File

@ -177,6 +177,9 @@ export interface Product {
export interface Cart { export interface Cart {
id: string; id: string;
totalAmount?: number | null; totalAmount?: number | null;
totalTaxAmount?: number | null;
currencyCode?: string | null;
totalQuantity?: number | null;
user?: (string | null) | User; user?: (string | null) | User;
lines?: lines?:
| { | {