Skip to content

Commit 061a15c

Browse files
committed
update cart
1 parent 22d3bdd commit 061a15c

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/app/Cart.jsx

+21-8
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useEffect } from 'react';
22
import CartProductNotFound from '../components/CartProductNotFound';
33
import { Link } from 'react-router-dom';
4-
import { BsCircleFill, BsChevronCompactRight, BsChevronCompactLeft } from "react-icons/bs";
4+
import { BsChevronCompactRight, BsChevronCompactLeft } from "react-icons/bs";
55
import '../css/Cart.css'
66

77
export default function Cart() {
@@ -128,7 +128,13 @@ export default function Cart() {
128128
}
129129
}
130130
};
131-
131+
132+
let totalPrice = 0;
133+
productDetails.map((product, index) => {
134+
totalPrice += product.price * product.quantity;
135+
});
136+
137+
132138

133139

134140
return (
@@ -166,7 +172,7 @@ export default function Cart() {
166172
</div>
167173
</div>
168174
<div className="d-flex flex-row align-items-center">
169-
<span className="d-block ml-5 font-weight-bold">${product.price}</span>
175+
<span className="d-block ml-5 font-weight-bold">${product.price * product.quantity}</span>
170176
<span className="d-block ml-5 font-weight-bold" id= "AddQuantity-RemoveQuantity">
171177
<BsChevronCompactLeft onClick={() => RemoveQuantity(product.id)} id="Leftİcon"/>
172178
{product.quantity}
@@ -211,15 +217,22 @@ export default function Cart() {
211217
<input type="text" className="form-control credit-inputs" placeholder="342" />
212218
</div>
213219
</div>
220+
<div>
214221
<hr className="line" />
215-
<div className="d-flex justify-content-between information"><span>Subtotal</span><span>$3000.00</span></div>
216-
<div className="d-flex justify-content-between information"><span>Shipping</span><span>$20.00</span></div>
217-
<div className="d-flex justify-content-between information"><span>Total(Incl. taxes)</span><span>$3020.00</span></div>
222+
<div className="d-flex justify-content-between information">
223+
<span>Subtotal</span>
224+
<span>{totalPrice }</span>
225+
</div>
226+
<div className="d-flex justify-content-between information">
227+
<span>Total (Incl. taxes)</span>
228+
<span>{totalPrice}</span>
229+
</div>
218230
<button className="btn btn-primary btn-block d-flex justify-content-between mt-3" type="button">
219-
<span>$3020.00</span>
220-
<span>Checkout<i className="fa fa-long-arrow-right ml-1"></i></span>
231+
<span>{totalPrice}</span>
232+
<span>Checkout <i className="fa fa-long-arrow-right ml-1"></i></span>
221233
</button>
222234
</div>
235+
</div>
223236
</div>
224237
</div>
225238
</div>

0 commit comments

Comments
 (0)