openfoodfoundation / openfoodnetwork

Connect suppliers, distributors and consumers to trade local produce.
https://www.openfoodnetwork.org
GNU Affero General Public License v3.0
1.12k stars 724 forks source link

Setting all available shipping methods as "backoffice only" hides all of them from the backoffice as well #6136

Open filipefurtad0 opened 4 years ago

filipefurtad0 commented 4 years ago

Description

Observed while testing #6039

PR #5392 introduced the possibility to set shipping methods as "backoffice only", removing them from the /checkout page.

Currently, the most common workflow for creating backoffice orders is (following a top-down order): 1) choosing distributor and OC 2) adding products (can't set shipping methods before adding customer info) 3) adding customer details 4) changing/adding/updating info on shipping methods, tracking info and updating fees 5) adding payment info

If the hub has set all hipping methods as backofice only, and follows this workflow/order, then no shipping methods are available to choose from - which is the bug reported in this issue.

Expected Behavior

Shipping methods - as seen on /admin/shipping_methods - should always be available in the backoffice (lets forget tags for now - as there is an ongoing discussion on this matter)

Actual Behaviour

If all shipping methods are set as "backoffice only" then no available shipping method appears when placing backoffice orders (this happens for the workflow described above)

Steps to Reproduce

Log in as admin

  1. Set all available shipping methods as "Backoffice only". You can double check this under /admin/shipping_methods
  2. Place an order. Follow the workflow shown described above (from top to down), i.e.:

choosing distributor and OC > adding products > adding customer details

  1. Try to changing/add/update info on shipping methods: See that no shipping methods are available, after adding customer details.

Animated Gif/Screenshot

image

Workaround

If one sets the customer details in forehand, then the backoffice-only set shipping methods appear as expected. That means following this workflow:

1) choosing distributor and OC 2) adding customer details 3) adding products 4) changing/adding/updating info on shipping methods, tracking info and updating fees 5) adding payment info

Severity

Not sure on severity. Maybe an edge case - bug-s4?

Your Environment

Possible Fix

filipefurtad0 commented 3 years ago

Adding the payment info and creating a new payment seems to trigger this error on Bugsnag: https://openfoodnetwork.slack.com/archives/CEF14NU3V/p1629799584026700

After seeing the error, refreshing the page shows that the payment was created, but the order is still on state = "payment":

image