Implement shopping cart with localStorage persistence and checkout integration#43
Draft
Implement shopping cart with localStorage persistence and checkout integration#43
Conversation
Co-authored-by: webmaxru <1560278+webmaxru@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Plan implementation for copilot project
Implement shopping cart with localStorage persistence and checkout integration
Mar 2, 2026
Owner
|
@copilot make final result screenshots using playwright mcp |
Author
Here are the Playwright screenshots showing the implemented shopping cart feature: Homepage – cart icon visible in the nav bar (empty state): Products page – all 12 products loaded with discount badges, quantity selectors, and "Add to Cart" buttons: Products page with cart badge – after adding 2 items, the badge updates live in the nav: Cart page – both items shown with discount labels, per-item quantity controls, line totals, grand total ($247.49), and Place Order / Continue Shopping actions: |
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.




The "Add to Cart" button on the Products page was a no-op (
alert()stub). This implements a full client-side cart backed bylocalStoragewith a checkout flow that creates real orders via the existing API.New
CartContext.tsx– React Context exposingaddToCart / updateQuantity / removeFromCart / clearCart / totalItems / totalPrice. Cart state hydrates from and syncs tolocalStorage. Exports sharedeffectivePrice(item)helper (discount-aware) used by both context and cart page to avoid divergence.Cart.tsx– Cart page at/cart: per-item quantity controls, line totals, grand total, and a checkout handler that POSTsOrder { branchId: 1, status: 'pending' }then fans outOrderDetail[]viaPromise.all.Modified
App.tsx– Wraps tree with<CartProvider>, adds/cartroute.Navigation.tsx– Cart icon with live item-count badge; usesuseCart().totalItems.Products.tsx– Replacesalert()stub withaddToCart({ productId, name, price, discount }, quantity).Data flow
Original prompt
Created from VS Code.
🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. Learn more about Advanced Security.