feat(plugin-ecommerce): expose method refreshCart in useCart (#14765) #14767
+23
−2
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.
What?
This PR adds a new method refreshCart to the E-commerce plugin.
Why?
Currently, the standard addItem method enforces uniqueness validation for products in the cart. This conflicts with certain use cases where the same product should be added as a new line item.
By exposing refreshCart, developers can manually refresh the cart state after directly modifying cart items, ensuring the UI stays in sync without being blocked by addItem’s uniqueness validation.
This addresses the feature request described in #14765
and the related discussion #14764
.
How?
Added refreshCart method to the E-commerce context.
This allows programmatic updates to the cart state without triggering the uniqueness validation of addItem.
The method can be called after direct modifications to the cart (e.g., via fetch requests or custom logic).
Fixes
Fixes #14765