Skip to content

Commit

Permalink
✨ display shipping amount
Browse files Browse the repository at this point in the history
  • Loading branch information
DuvCharles committed Nov 21, 2023
1 parent e194d3e commit 45c1b67
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
6 changes: 5 additions & 1 deletion components/cart/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,11 @@ export default function CartModal({ cart }: { cart: Cart | undefined }) {
</div>
<div className="mb-3 flex items-center justify-between border-b border-neutral-200 pb-1 pt-1 dark:border-neutral-700">
<p>Shipping</p>
<p className="text-right">Calculated at checkout</p>
<Price
className="text-right text-base text-black dark:text-white"
amount={cart.cost.shippingAmount.amount}
currencyCode={cart.cost.shippingAmount.currencyCode}
/>
</div>
<div className="mb-3 flex items-center justify-between border-b border-neutral-200 pb-1 pt-1 dark:border-neutral-700">
<p>Total</p>
Expand Down
3 changes: 2 additions & 1 deletion lib/sylius/normalizer/cart-normalizer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ export const normalizeCart = (syliusCart: SyliusCart): Cart => {
cost: {
subtotalAmount: normalizePrice(syliusCart.itemsTotal),
totalAmount: normalizePrice(syliusCart.total),
totalTaxAmount: normalizePrice(syliusCart.taxTotal)
totalTaxAmount: normalizePrice(syliusCart.taxTotal),
shippingAmount: normalizePrice(syliusCart.shippingTotal)
},
lines: syliusCart.items.map((item) => normalizeCartItem(item)),
totalQuantity: syliusCart.items.reduce((acc, item) => acc + item.quantity, 0)
Expand Down
1 change: 1 addition & 0 deletions lib/sylius/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export interface Cart {
subtotalAmount: Money;
totalAmount: Money;
totalTaxAmount: Money;
shippingAmount: Money;
};
lines: CartItem[];
totalQuantity: number;
Expand Down

0 comments on commit 45c1b67

Please sign in to comment.