Repository navigation
Support adding items to cart without logging in - #156
TanmayS0406 wants to merge 21 commits into
Conversation
|
@captainsafia are you going to review this or anyone else will continue with review process? 😕 |
|
@ks1990cn Considering the scope of this change, we may want to incorporate other reviewers in here, but I can take a look for now. Have you verified that this works end-to-end? I'm not able to checkout after adding an item to the cart while being logged out. |
Correct me if I misunderstood, as per issue #27 , we should be able to add item to cart when user is not logged-in. User need to log-in before check out. On this functionality I have worked on. |
Thanks for sharing the recording. For whatever reason, I don't see the same behavior when I repro locally. The "Checkout" button doesn't redirect to the login page... |
I am not sure, can you ask anyone else to try this? |
Take recent code changes, I have made commits after our last comments!! @captainsafia |
|
@captainsafia I am waiting for PR review again🥺🥺, is there any luck with running it locally? |
captainsafia
left a comment
There was a problem hiding this comment.
I realized why it was failing to redirect to the login page -- seems to be an issue with my browser and not the code change.
Tagging @mgravell to sanity check the use of distributed caching here.
|
@captainsafia can you please review again, made requested changes? |
|
@jamesmontemagno @adityamandaleeka Looks like you also work on this repo, can you review this if @captainsafia is no more looking in this PR. Just wanted to know till when I can expect review again? I'm so excited to continue contribution on this! |
|
Hii @captainsafia , will you gonna see this PR again? It's been long time now |
|
@ks1990cn Thanks for your eagerness here, Tanmay! At the moment, we're trying to prioritize bug fixes and quality improvements on eShop before taking new features so we'd like to hold off on merging this change at the moment. |
|
@captainsafia any update on this pr? this feature is very much needed for my scenario. |
|
@cwash05 As @captainsafia mentioned above, we're prioritizing quality/fixes in this project for now so we are holding off on adding functionality. It's not clear what you mean by this being needed for your scenario. This PR has no impact on the product capabilities of ASP.NET Core, Aspire, or any other technology we ship; this repo/project is merely a sample. |
Conflict in ItemPage.razor: kept main's new item page layout (back link, image zoom, item-buy section, price formatting) and re-applied this branch's change on top of it, so the add-to-cart form no longer depends on being logged in and always shows the "Add to shopping bag" button. BasketState implements IBasketState again. The interface had been dropped on this branch, and main's ChatState now takes an IBasketState, so the WebApp did not compile without it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Moves the logged-in/anonymous decision into BasketState so callers no longer branch on it. Until the user logs in, the basket is kept in the session; on login it is merged into the basket saved for the user (quantities are summed) instead of replacing it. - BasketState: GetBasketItemsAsync, AddAsync and SetQuantityAsync work for both kinds of user; the session is read on demand, so BasketState no longer fails when there is no HttpContext (e.g. the chatbot circuit). - Anonymous users can now change quantities and remove items in the bag. - ItemPage shows the "in your bag" count for anonymous users on load. - CartPage no longer requires login; checkout still does. - Checkout sends a user who is not logged in to the login page instead of placing the order. - The login cookie is rejected once its access token has expired, so the user is treated as logged out instead of hitting Unauthenticated from the Basket API. - The chatbot's add-to-cart tells anonymous users to log in. - Adds e2e tests for adding while logged out and for keeping the items after logging in. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Rejecting a login cookie whose access token has expired fixes a separate, existing problem (any basket write fails with Unauthenticated once the token is older than 2 hours) and is not needed to support an anonymous cart. It can be proposed on its own. Also drops a stray blank line in AddApplicationServices. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Hi @captainsafia @adityamandaleeka , Years have passed still even no one looked into this PR. I have updated PR with latest code after claude PR review. Can you confirm what is your priority these days? Please reivew this PR before I retire from software industry 🤣 |
The quantities of the session basket and the saved basket were added up as int, which throws OverflowException at login when they are large enough. Add them as long and clamp the result to int.MaxValue. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>

closes #27 , changes are related to WebApp.
I want to propose an idea to store cart objects into session untill user log-in. When user log-in, this session cart will be converted into redis cart for user.