bleroy / Nwazet.Commerce

Idiomatic commerce module for Orchard CMS.
BSD 3-Clause "New" or "Revised" License
26 stars 21 forks source link

Carts and wishlists #122

Closed MatteoPiovanelli-Laser closed 7 years ago

MatteoPiovanelli-Laser commented 7 years ago

Work on #117 This PR contains the first portion of the work related to persistent carts and wishlists.

There is no wishlist functionality yet.

the ShoppingCart is treated as a content type with a ProductsListPart to store an authenticated user's cart in the item's infoset.

If a user already has a cart, we do not create a new one.

If a user is not logged in, their cart is stored as it was, using local storage and session storage.Once the user logs in, whatever they had in their carts gets merged into the persistent cart, and session and local storage are kept empty as long as the user is logged in. To keep the local storage clear, I had to change the shoppingcart.js scripts a bit. Note that I did not change the minified version yet

Besides handling the peculiarity of login/logout scenarios, the cart works normally: items can be added/removed/updated, the cart is emptied on checkout and so on.

NOw I'll get to implementing the functionality of wishlists.

MatteoPiovanelli-Laser commented 7 years ago

An update to the PR is coming soon.

MatteoPiovanelli-Laser commented 7 years ago

Hi,

I am back on this after the past couple of weeks working on the concurrency issues of Orchard.

I wrote the serialization. I preferred the version that was serializing twice, honestly, because the code was more compact, and it was less likely to require updates in case the classes get changed.

MatteoPiovanelli-Laser commented 7 years ago

There are issues in this PR with the scripts. To reproduce them:

Have a cart with 2+ different items. Open a page that shows the cart widget. Hit "remove" for one item (this works). Hit "remove for the second item (this does notcall the controller).

Likewise, "Update all" works only once.

I probably messed something up when I updated the scripts to handle local storage differently.

MatteoPiovanelli-Laser commented 7 years ago

I think I made the changes per your review of the serialization part

I fixed the bug with shoppingcart.js

bleroy commented 7 years ago

Thanks, I think this looks pretty good. I have one final comment on parsing ints from XML.

MatteoPiovanelli-Laser commented 7 years ago

I updated the branch.

A few considerations:

bleroy commented 7 years ago

Thanks!