Closed MatteoPiovanelli-Laser closed 7 years ago
public abstract class ShoppingCartBase : IShoppingCart
with virtual implementations. ShoppingCart
and PersistentShoppingCart
inherit from that.Store
method seems to not accept the types here. I gave a quick look in the sources, and I think the issue lies with the XmlHelper.ToString<T>
method. FOr now, I am keeping the double serialization using Newtonsoft.Json.An update to the PR is coming soon.
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.
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.
I think I made the changes per your review of the serialization part
I fixed the bug with shoppingcart.js
Thanks, I think this looks pretty good. I have one final comment on parsing ints from XML.
I updated the branch.
A few considerations:
ProductsListPart
has a bool IsCart
property. This is of course true
for carts. However that property is currently not used anywhere else. For wishlists, I am doing things slightly different, as I outlined in #117.Thanks!
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.