Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does OFN count the number of incomplete orders? #5236

Closed
RachL opened this issue Apr 15, 2020 · 12 comments · Fixed by #8148
Closed

How does OFN count the number of incomplete orders? #5236

RachL opened this issue Apr 15, 2020 · 12 comments · Fixed by #8148
Assignees
Labels
bug-s3 The bug is stopping a critical or non-critical feature but there is a usable workaround. UK Selected to be done by the UK active instance

Comments

@RachL
Copy link
Contributor

RachL commented Apr 15, 2020

Description

I have a user with 747 uncompleted orders. He is a bit worried because he never had any real orders. So he is afraid people don't manage to order...

Steps to Reproduce

See uncompleted orders for hub 730 in French production

Animated Gif/Screenshot

image

Severity

bug-s3: a feature is broken but there is a workaround

Your Environment

  • Version used: v2.9.2
  • Browser name and version: Firefox 76
  • Operating System and version (desktop or mobile): Desktop
@RachL RachL added the bug-s3 The bug is stopping a critical or non-critical feature but there is a usable workaround. label Apr 15, 2020
@lin-d-hop
Copy link
Contributor

This number is based on the number of incomplete carts.
But for some reason OFN creates WAAAAY more carts that people actually need. A shopper will create a bunch of carts in the process of getting to checkout.

This quirk is coming up in all kinds of discussions at the moment so I think we might be working on it soon :-)

@luisramos0
Copy link
Contributor

👍
I looked at FR live and this user is an outlier with 700+ carts, but I saw quite a few users with around 100 carts...
We need to create a new cart when the user changes shop but I dont think we should create a new cart when the user comes back after a few days for example.

@sigmundpetersen sigmundpetersen changed the title How does OFN count the number of uncomplete orders? How does OFN count the number of incomplete orders? May 26, 2020
@lin-d-hop lin-d-hop added the UK Selected to be done by the UK active instance label Aug 4, 2021
@lin-d-hop
Copy link
Contributor

I want to solve this properly as UK's S3 this round :trollface:

@openfoodfoundation/train-drivers-product-owners We need to define the correct behaviour in order to solve this issue :-)

@RachL
Copy link
Contributor Author

RachL commented Aug 4, 2021

I would say that as soon as an item is put in cart, the order should show as incompleted.

If the shopper comes back, it would be nice to use the same cart and not open a new one.

All the other cases where we open a cart (like when someone is visiting a shop), if we need them for technical reason, let's keep them. But we need to remove them from the list of uncompleted orders?

@jaycmb
Copy link
Collaborator

jaycmb commented Aug 4, 2021

I would say that as soon as an item is put in cart, the order should show as incompleted.

Current behaviour is order is in state cart as soon as items are selected (and stays in this state until payment +shipment selected and shopper clicked 'place order').

All the other cases where we open a cart (like when someone is visiting a shop)

We open a cart automatically when someone is visiting a shop?!

If the shopper comes back, it would be nice to use the same cart and not open a new one.

That would be nice indeed, but sounds like more complicated.
Should that involve showing the shopper previously saved items in the cart? Or only "reuse" previously generated cart/order if a user returns within a certain time period after having abandoned the cart (e.,g. because switching to another shop within same session)?

@RachL
Copy link
Contributor Author

RachL commented Aug 4, 2021

Current behaviour is order is in state cart as soon as items are selected

@jaycmb are you sure of this? Many of the cart currently opened do not have any items.

We open a cart automatically when someone is visiting a shop?!

More specifically, each time the person is login back in, see the discussion that has generated the issue:

https://openfoodnetwork.slack.com/archives/CG7NJ966B/p1586458155387700

but sounds like more complicated.

I'm not so sure about that. It sounds like Luis mentioned it above ☝️

We need to create a new cart when the user changes shop but I dont think we should create a new cart when the user comes back after a few days for example.

If the user switch shops he is loosing the cart, I think we should keep this behavior.

@RachL
Copy link
Contributor Author

RachL commented Sep 1, 2021

@apricot12 @jibees if one of you picks this s3 up, the only task for now is to do a spike to understand in which cases today we open a cart. From there we will create other issues to remove or add cases where we open a cart.

Is the data in this issue useful or should I close it and just open a spike issue?

@jibees jibees self-assigned this Sep 2, 2021
@jibees
Copy link
Contributor

jibees commented Sep 2, 2021

Regarding the code, and assuming that an order (ie. a cart) is opened when calling lib/spree/core/controller_helpers/order.rb@current_order(true), we do create an order (if it does not exist) in the following place:

  • app/controllers/base_controller.rb#38: when we set an order_cycle
  • app/controllers/cart_controller.rb#7: POST on /cart/populate. Called by app/assets/javascripts/darkswarm/services/cart.js.coffee@adjust() via update() each time we edit a ship variant
  • app/controllers/enterprises_controller.rb#66: GET on /:id/shop when order has insufficient_stock_lines (and then redirect to /)
  • app/controllers/enterprises_controller.rb#70: when calling reset_order ie. each prepend_before_action on /shop
  • app/controllers/shop_controller.rb#15: POST on /shop/order_cycle
  • app/controllers/spree/orders_controller.rb#43: GET on /orders/:id/edit
  • app/controllers/spree/orders_controller.rb#112: PATCH on /orders/:id
  • app/helpers/shared_helper.rb#5: called via view app/views/shared/_distributor.html.haml
  • app/services/order_completion_reset.rb#28: seems to be used for the "continue shopping" feature once an order is completed.
  • lib/spree/core/controller_helpers/order.rb#80: not sure to understand but seems to be called each time we use Order (via before_action on base.class_eval)...

Saying that, I'm afraid that it is totally useless, because it seems to be called/used a lot.

(Next step: try to recreate each step functionally (ie. as a user/admin) that leads to these lines.)

I'm wondering if there is an opportunity to log (with a certain level of severity, or a certain tag, or whatever, ...) each time an order is actually created (on lib/spree/core/controller_helpers/order.rb#41) with its own stack and then understand where does this empty cart comes from.
Certainly a question more for @openfoodfoundation/core-devs

@Matt-Yorkley
Copy link
Contributor

Yeah, there's lots of places where we create or discard carts for various reasons. I'm not sure we can easily remove them...

@kirstenalarsen
Copy link
Contributor

kirstenalarsen commented Sep 2, 2021 via email

@mkllnk
Copy link
Member

mkllnk commented Sep 6, 2021

I guess that you need to look at carts with items in there and ignore the empty carts because they get created all the time.

@RachL
Copy link
Contributor Author

RachL commented Sep 7, 2021

thanks @mkllnk for the suggestion! At delivery train today we decided that as a first step here we would hide uncompleted order with no line items from the user. This should close this s3 for now. @jibees it's all yours!

In parallel, we need to work on our metrics like conversion rates, both for our users but also to correctly assess the impact of the new slipt checkout work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-s3 The bug is stopping a critical or non-critical feature but there is a usable workaround. UK Selected to be done by the UK active instance
Projects
None yet
8 participants