fix: properly clear cart after order placement

- Use clearCart() from store instead of iterating removeItem()
- Iteration could fail as items are removed during loop
- clearCart() resets cart to initial state atomically
This commit is contained in:
Dwindi Ramadhana
2025-12-31 22:18:06 +07:00
parent f79938c5be
commit f97cca8061

View File

@@ -237,10 +237,8 @@ export default function Checkout() {
const data = (response as any).data || response;
if (data.ok && data.order_id) {
// Clear cart
cart.items.forEach(item => {
useCartStore.getState().removeItem(item.key);
});
// Clear cart - use store method directly
useCartStore.getState().clearCart();
toast.success('Order placed successfully!');
navigate(`/order-received/${data.order_id}?key=${data.order_key}`);