Skip to content

Commit 240ad1f

Browse files
committed
feat: clear local cart after successful order
1 parent 863c734 commit 240ad1f

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/pages/shop/OrderSummaryPage.jsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ function Checkout() {
2727

2828
const [isOpen, setIsOpen] = useState(false);
2929

30+
const clearLocalStorageCart = () => {
31+
localStorage.setItem("swagList", []);
32+
};
33+
3034
const handleSubmit = (data) => {
3135
const payload = {
3236
city: `${data.address.city}, ${data.address.country}`,
@@ -39,6 +43,9 @@ function Checkout() {
3943
if (successfulOrder) {
4044
// clear session cart
4145
clearCart();
46+
47+
// delete local storage cart
48+
clearLocalStorageCart();
4249
}
4350
};
4451

0 commit comments

Comments
 (0)