There's no 'Save For Later', and there's no 'Empty Cart' or 'Discard Cart'.
While carts are never removed from the database, they are discarded
after the gateway reports acceptance of the payment:
@cart.user_id = nil
@cart.save
session[:cart_id] = nil
session[:order_id] = nil
Currently, this is the only way a cart gets discarded. That's a
problem probably most easily fixed with an 'Empty Cart' link or button.
If I add this, then if a user is signed in, I can give them their
most recent cart only if there is no cart pointed to by the session.
No cart is lost by signing in, and if they don't like the contents of
the cart, they can discard it.
Out of several alternatives, that changes the operation of the site
the least, I think. The status quo is no good, though.
Scott
At 01:37 PM 12/6/2009, you wrote:
>Quoting Scott Olmsted <[email protected]>:
> > def get_cart
> > @cart = @user.cart unless @user.blank?
> > @cart = Cart.find_by_id(session[:cart_id]) if @cart.blank? &&
> > !session[:cart_id].blank?
> > end
> >
> > While it is not required that one sign in to make a purchase, if I am
> > signed in, then get_cart first goes and looks for a cart of mine in
> > the database. This makes informal testing difficult because it means
> > I can't discard a cart by deleting the cookie, I can't start over!
> >
> > A more serious problem with tying a cart to a user is that someone
> > could add items to a new cart, then log in and find themselves
> > looking at an old cart they had when last logged in, losing the newer
> > cart they were using. Maybe the developer wanted to make sure a
> > user's cart was never lost, but this is a bad side effect.
> >
> > So am I right in thinking that a cart should not be tied to a user?
> > Or at least the logic in get_cart should be reversed: look first for
> > a cart pointed to by the session, then look for one belonging to the user?
>
>Does the UI imply some sort of "save for later" feature? I am guessing
>that this logic is trying to let users log in to save their cart to
>finalized the purchase later. But that only really works if carts
>disappear when the order is placed. Otherwise you might get an old
>cart full of stuff you already received.
>
>--
>Cynthia Kiser
>[email protected]
>
>--
>SD Ruby mailing list
>[email protected]
>http://groups.google.com/group/sdruby
--
SD Ruby mailing list
[email protected]
http://groups.google.com/group/sdruby