diff --git a/package-lock.json b/package-lock.json index d01ddfa..bbd664e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5,6 +5,7 @@ "requires": true, "packages": { "": { + "name": "react-ecommerce", "version": "0.0.1", "dependencies": { "@headlessui/react": "^1.6.0", diff --git a/src/Components/Cart.jsx b/src/Components/Cart.jsx index 917b7a1..18d0c34 100644 --- a/src/Components/Cart.jsx +++ b/src/Components/Cart.jsx @@ -3,6 +3,10 @@ import { XIcon } from "@heroicons/react/outline"; import React, { Fragment } from "react"; export default function Cart({ open, setOpen, cart, updateCart }) { + var subtotal = 0; + cart.forEach(product => { + subtotal += product.price + }) return (

Subtotal

-

$262.00

+

{subtotal}

Shipping and taxes calculated at checkout.

diff --git a/src/Components/ProductTable.jsx b/src/Components/ProductTable.jsx index ea76621..08d0dcf 100644 --- a/src/Components/ProductTable.jsx +++ b/src/Components/ProductTable.jsx @@ -41,8 +41,9 @@ export default function ProductTable({ cart, updateCart }) { setProducts(body); }; fetchProducts(); - }); + }, []); + return (