Skip to content

Commit f3b1986

Browse files
committed
Fix productsCount
1 parent 68b602e commit f3b1986

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

components/Cart/Cart.component.jsx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ import Link from 'next/link';
44
import { AppContext } from 'utils/context/AppContext';
55

66
/**
7-
* Displays the shopping cart contents. *
7+
* Displays the shopping cart contents. *
88
* Displays amount of items in cart.
99
*/
1010
const Cart = ({ stickyNav }) => {
1111
const [cart] = useContext(AppContext);
1212

13-
const productsCount =
14-
null !== cart && Object.keys(cart).length ? cart.totalProductsCount : '';
13+
const productsCount = cart.cart.contents.nodes.reduce(
14+
(total, product) => total + product.quantity,
15+
0
16+
);
1517

1618
return (
1719
<>
18-
1920
<Link href="/handlekurv">
2021
<span
2122
className="pl-4 mt-4 no-underline inline-block"

0 commit comments

Comments
 (0)