Hey fall_0ut,
Thanks for the nice module.
I was thinking about implement a similar module when i found yours. The approach i thought about was a bit different from yours. While i'm not sure it would be any better than yours i'd like to hear your thoughts.
Commerce allows to handle multiple cart per users, including multiple "active" cart (1 user can have many carts in Cart status). Why not create a "Wishlist" order state, and allow the user to add products to it.
-> If the user clicks on add to wishlist button : it adds it to the user's cart in wishlist state
-> If the user remove a product from the wishlist, it's simply removing it from the cart
-> If the user transfer a wishlist product to the cart, we duplicate the line item and remove from the wishlist
etc..
I'm not sure about the pros / cons of this solution, i'm just wondering if this integration wouldn't be better for future use with other modules (stock, cart features...)
Pascal
Comments
Comment #1
dydave commentedHi Pascal,
That sounds like a very good idea.
What you are suggesting is to use an order object instead of creating another entity, for the wishlist.
I would say that all solutions have pros and cons, but in this case, I tend to think that things are perhaps a little easier to handle as they are right now, since adding a wishlist status and manipulation on order objects would probably have to go through the Commerce module which is most likely much harder to get changed... if you know what I mean.
In terms of integration, if things get to a critical level with this module, it could always be considered to be moved back in to Commerce as you suggest with a rewrite partly inspired with these features.
Do you see anything that could be done with the method you're suggesting and could not be done with the current implementation?
As I see it, mostly one thing would be missing:
move order from wishlist to cart == add all items from user's wishlist to cart.
This could be added to another ticket and to the module as callback, easily.
Anything else?
Thanks in advance!
Comment #2
imiksuI like this approach too, this sounds like 2.x base idea ;)
This approach would allow also use wishlists for anonymous users, right? (#2080829: Wishlist for anonymous users)
Comment #3
jeroent@iMiksu, In issue https://drupal.org/node/1350342
rszrama said :
Drupal Commerce already supports multiple carts per user, though it only supports this for logged in users. The current cart order is simply the last created order in a cart status for the given user. This means you can create and manage multiple carts for registered users just fine - you just need to implement your own logic for determining which cart order to use when. We have a hook for getting the current user's cart order ID (defaults to the latest order as I mentioned above), and that hook can be used to make multiple cart functionality work for anonymous users and implement logic for determining which cart is the current one.
So it should be possible using hook_commerce_cart_order_id().
Comment #4
dubcanada commentedI don't think this would provide any benefit over the current implementation and would just lead to more work getting it to do stuff properly. Wishlists are just lists of stuff you want, stock, features, taxes, etc don't matter at that point. The only point with which that stuff matters is when wishlist is moved from a wishlist to the cart.
Comment #5
smccabe commentedThe 3.x version now uses this architecture, so closing this issue.