Bug Description
When a user adds products to the shopping cart and refreshes the page, all cart items are lost and the cart becomes empty. This negatively impacts the shopping experience because users expect their selected items to remain available until they intentionally remove them.
Steps to Reproduce
- Open the website.
- Navigate to the Shop page.
- Add one or more products to the cart.
- Open the Cart page and verify the items are present.
- Refresh the page or reopen the website.
Current Behavior
The shopping cart is cleared after page refresh, and all previously added items disappear.
Expected Behavior
Cart data should persist across page reloads. Products added to the cart should remain available after refreshing the page or reopening the browser tab.
Possible Cause
The cart state is currently maintained only in memory and is not being stored in browser storage.
Proposed Solution
- Store cart data in localStorage whenever items are added, removed, or updated.
- Load saved cart data from localStorage when the application initializes.
- Validate stored data before rendering the cart.
- Ensure cart totals and quantities are restored correctly.
Acceptance Criteria
- Cart items remain available after page refresh.
- Cart data persists across browser sessions.
- Quantity updates are preserved.
- Cart totals are calculated correctly after restoration.
- No console errors occur when localStorage is empty or contains invalid data.
Suggested Labels
bug, javascript, enhancement, gssoc26
Bug Description
When a user adds products to the shopping cart and refreshes the page, all cart items are lost and the cart becomes empty. This negatively impacts the shopping experience because users expect their selected items to remain available until they intentionally remove them.
Steps to Reproduce
Current Behavior
The shopping cart is cleared after page refresh, and all previously added items disappear.
Expected Behavior
Cart data should persist across page reloads. Products added to the cart should remain available after refreshing the page or reopening the browser tab.
Possible Cause
The cart state is currently maintained only in memory and is not being stored in browser storage.
Proposed Solution
Acceptance Criteria
Suggested Labels
bug, javascript, enhancement, gssoc26