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:
@@ -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}`);
|
||||
|
||||
Reference in New Issue
Block a user