spree/spree — pull request #1231 by kunalchaudhari (2012-03-05 08:07:38+00:00)
Title: #1066 fix cart empty after logout and login again

Cart goes empty when user logout and login again. This fix resolve this issue.

It does by copying line_items to logged in user's last incomplete order from session order. Because when user log in we should concern with line_items in session order as other details (addresses, shipping method etc) will be chosen by user during checkout. This will also not override user defaults if any (like saved addresses).

It basically populate the line_items by calling add_variant method. And when user do checkout adjustments will be calculated as done for normal checkout flow. Another advantage of this is that for logged in order there will be only one incomplete order in database. unless he completes the order he will be working with incomplete order only.

When there is no incomplete order than session order will be associated with current_user (which is current situation for all scenario).