Fix cart items not visible on return visit until new item added#4586
Merged
del22123 merged 4 commits intomagento:developfrom Jan 20, 2026
Merged
Fix cart items not visible on return visit until new item added#4586del22123 merged 4 commits intomagento:developfrom
del22123 merged 4 commits intomagento:developfrom
Conversation
- Add useEffect to load cart from localStorage on component mount - When cardId exists in storage but Redux state is empty.different, trigger loadCart to restore persisted car items - Fixes magento#4585
Collaborator
LogERROR ON TASK: cypressTests |
Collaborator
Collaborator
|
Collaborator
LogDetailsERROR ON TASK: lighthouseTests |
glo82145
approved these changes
Jan 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Added a
useEffecthook to theCartContextProvidercomponent that automatically loads the cart from localStorage when the component mounts. This ensures that when users return to the application after closing the tab or reloading the page, their previously added cart items are restored.The effect checks if a
cartIdexists in localStorage, and if the ReduxcartStateis either empty or has a differentcartId, it triggersasyncActions.getCartDetails()to fetch and restore the persisted cart data.Related Issue
Closes #4585
Acceptance
Verification Stakeholders
Specification
Verification Steps
cartIdis stored in localStorage)Test scenario(s) for direct fix/feature
Test scenario(s) for any existing impacted features/areas
Test scenario(s) for any Magento Backend Supported Configurations
Is Browser/Device testing needed?
Any ad-hoc/edge case scenarios that need to be considered?
Screenshots / Screen Captures (if appropriate)
Breaking Changes (if any)
Checklist