import type { GetStaticPropsContext } from 'next' import { getConfig } from '@bigcommerce/storefront-data-hooks/api' import getAllPages from '@bigcommerce/storefront-data-hooks/api/operations/get-all-pages' import useCart from '@bigcommerce/storefront-data-hooks/cart/use-cart' import usePrice from '@bigcommerce/storefront-data-hooks/use-price' import { Layout } from '@components/core' import { Button } from '@components/ui' import { CartItem } from '@components/cart' import { Text } from '@components/ui' import CartSkeleton from '@components/cart/CartSkeleton' import CartEmpty from '@components/cart/CartEmpty' export async function getStaticProps({ preview, locale, }: GetStaticPropsContext) { const config = getConfig({ locale }) const { pages } = await getAllPages({ config, preview }) return { props: { pages }, } } export default function Cart() { const { data, error } = useCart() const isLoading = data === undefined const items = data?.line_items.physical_items ?? [] const { price: subtotal } = usePrice( data && { amount: data.base_amount, currencyCode: data.currency.code, } ) const { price: total } = usePrice( data && { amount: data.cart_amount, currencyCode: data.currency.code, } ) return (
My Cart {error ? (
Failed to load
) : isLoading ? ( ) : items.length > 0 ? (
Review your Order
    {items.map((item) => ( ))}
Before you leave, take a look at these items. We picked them just for you:
{[1, 2, 3, 4, 5, 6].map((x) => (
))}
  • Subtotal {subtotal}
  • Taxes Calculated at checkout
  • Estimated Shipping FREE
Total {total}
) : ( )}
) } Cart.Layout = Layout