diff --git a/components/cart/CartSidebarView/CartSidebarView.tsx b/components/cart/CartSidebarView/CartSidebarView.tsx
index 5cd409559..0e0f5e5e9 100644
--- a/components/cart/CartSidebarView/CartSidebarView.tsx
+++ b/components/cart/CartSidebarView/CartSidebarView.tsx
@@ -92,11 +92,11 @@ const CartSidebarView: FC = () => {
My Cart
- {data?.items?.map((item) => (
+ {data!.lineItems.map((item) => (
))}
diff --git a/framework/bigcommerce/cart/use-cart.tsx b/framework/bigcommerce/cart/use-cart.tsx
index 9cdd8f56c..75d81a1fb 100644
--- a/framework/bigcommerce/cart/use-cart.tsx
+++ b/framework/bigcommerce/cart/use-cart.tsx
@@ -34,9 +34,7 @@ export function extendHook(
descriptors: {
isEmpty: {
get() {
- return Object.values(response.data?.line_items ?? {}).every(
- (items) => !items.length
- )
+ return (response.data?.lineItems.length ?? 0) <= 0
},
enumerable: true,
},
diff --git a/framework/bigcommerce/lib/normalize.ts b/framework/bigcommerce/lib/normalize.ts
index 3827989f1..742f750d5 100644
--- a/framework/bigcommerce/lib/normalize.ts
+++ b/framework/bigcommerce/lib/normalize.ts
@@ -69,14 +69,30 @@ export function normalizeProduct(productNode: any): Product {
}
export function normalizeCart(data: BigcommerceCart): Cart {
- const d: BaseCart = data && {
+ // const d: BaseCart = data && {
+ // id: data.id,
+ // customerId: String(data.customer_id),
+ // email: data.email,
+ // createdAt: data.created_time,
+ // currency: data.currency,
+ // taxesIncluded: data.tax_included,
+ // lineItems: data.line_items as any,
+ // lineItemsSubtotalPrice: data.base_amount,
+ // subtotalPrice: data.base_amount + data.discount_amount,
+ // totalPrice: data.cart_amount,
+ // discounts: data.discounts?.map((discount) => ({
+ // value: discount.discounted_amount,
+ // })),
+ // }
+
+ return {
id: data.id,
customerId: String(data.customer_id),
email: data.email,
createdAt: data.created_time,
currency: data.currency,
taxesIncluded: data.tax_included,
- lineItems: data.line_items as any,
+ lineItems: data.line_items.physical_items.map(itemsToProducts) as any,
lineItemsSubtotalPrice: data.base_amount,
subtotalPrice: data.base_amount + data.discount_amount,
totalPrice: data.cart_amount,
@@ -85,14 +101,14 @@ export function normalizeCart(data: BigcommerceCart): Cart {
})),
}
- return update(data as any, {
- $auto: {
- items: { $set: data?.line_items?.physical_items?.map(itemsToProducts) },
- subTotal: { $set: data?.base_amount },
- total: { $set: data?.cart_amount },
- },
- $unset: ['created_time', 'coupons', 'line_items', 'email'],
- })
+ // return update(data as any, {
+ // $auto: {
+ // items: { $set: data?.line_items?.physical_items?.map(itemsToProducts) },
+ // subTotal: { $set: data?.base_amount },
+ // total: { $set: data?.cart_amount },
+ // },
+ // $unset: ['created_time', 'coupons', 'line_items', 'email'],
+ // })
}
function itemsToProducts(item: any): CartItem {
diff --git a/framework/commerce/types.d.ts b/framework/commerce/types.d.ts
index eb178619d..c31784984 100644
--- a/framework/commerce/types.d.ts
+++ b/framework/commerce/types.d.ts
@@ -114,7 +114,7 @@ interface BaseCart {
currency: { code: string }
// Specifies if taxes are included in the line items.
taxesIncluded: boolean
- lineItems: Pick & CartItem[]
+ lineItems: BaseLineItem[]
// The sum of all the prices of all the items in the cart.
// Duties, taxes, shipping and discounts excluded.
lineItemsSubtotalPrice: number