What is the need / problem
As a shopper, when I am logged in I would like my cart to persist for the hub I am shopping with. I would like OFN to remember the last cart that I created such then if I log out and log back in again the last cart is persisted.
If I change enterprises, order cycles or the order cycle closes my cart should not persist.
Who does it impact
What is the current impact of this problem
Currently if a user is shopping with one enterprise, then they switch to another enterprise their cart is cleared from the scope. This behaviour is enables multiple shopfronts to exist simultaneously. However the majority of shoppers only shop from a single hub. Therefore there is a clear benefit for a customers cart to persist if they log out and log back in to shop at the same hub.
What is the benefit in focusing on this
Improve user experience hen they log out and get back to the shop to finish to shop.
Links to more details
- GH issue: https://github.com/openfoodfoundation/openfoodnetwork/issues/1031
- GH PR: https://github.com/openfoodfoundation/openfoodnetwork/pull/1698
Potential solutions that will solve this problem
- (Lynne) The spree_order model enables carts to be persisted to a user and spree_line_items are also persisted. So to my understanding this issue is pertaining to reloading the cart to the scope when a user logs back in, with some checks to ensure the order cycle has not closed. Existing functions to clear the cart upon changing order_cycle or enterprise should be maintained.
- (Rob) We would simply be tweaking the current_order method in lib/spree/core/controller_helpers/order_decorator.rb to make it search the database for a relevant incomplete order, in the event that there is no order_id in the session.
If this search was restricted to incomplete orders owned by the current user, for the current shop and in the current order cycle, I can’t see a problem with it.
- See all tech discussions on the GH PR and issue