woocommerce / woocommerce

A customizable, open-source ecommerce platform built on WordPress. Build any commerce solution you can imagine.
https://woocommerce.com
9.43k stars 10.77k forks source link

Adding items to order in backend with negative qty results in error #31068

Open senff opened 3 years ago

senff commented 3 years ago

Describe the bug When editing an order in the backend, it is possible to add a product with a negative quantity. However, after that, the Update button does not work anymore. Error in console: "_An invalid form control with name 'order_itemqty[2767] is not focusable."

Expected behavior Either it should be made impossible to add a product with a negative quantity, OR the Update button should work again after that.

Actual behavior I believe it should not be possible to add products with a negative quantity to begin with.

Steps to reproduce the bug (We need to be able to reproduce the bug in order to fix it.) Steps to reproduce the bug:

  1. In the backend, open an order that can be edited (e.g. "Pending Payment")
  2. Add an item to the order with quantity -1 (you have to type it, as the arrows will only let you go to 0).
  3. Select the Update button.

Screenshots https://d.pr/i/4zDXYS

Isolating the problem (mark completed items with an [x]):

csmcneill commented 3 years ago

Reported in 4421567-zen

amalg commented 3 years ago

In response to the "Actual behavior" section where @senff states "I believe it should not be possible to add products with a negative quantity to begin with.", my thought here is that you should consider woocommerce as the central component of a rich and diverse ecosystem of integrations with various 3rd party for things like ERP, accounting, and inventory control. We currently use this negative qty line item approach to handle RMAs and product exchanges with 3rd party inventory control and accounting products that do successfully pull this data in and make proper use of it. Since woocommerce already functions properly in every other regard with orders that have negative qty line items, we simply need the update button to function to record changes to order details such as status, shipping address, etc.

tammullen commented 3 years ago

Hi @senff

Thank you for taking the time to report this bug, we really appreciate your help. I can reproduce it on my end.

If I edit the product quantity in an existing order and press update I get a warning Screenshot 2021-11-05 at 21 25 48

If I edit the product quantity in an existing order and press save and then press update I get the console message Screenshot 2021-11-05 at 21 30 09

Screenshot 2021-11-05 at 21 30 17

An invalid form control with name='order_item_qty[43]' is not focusable.

Priority of this issue will be assigned shortly after we'd go through a round of prioritization. Please note it may take a couple of days.

As far as what the expected behaviour is, this requires further feedback from the WooCommerce Core team. I am adding the needs developer feedback label to this issue so that the Core team could take a look.

Please note it may take a few days for them to get to this issue. Thank you for your patience.

barryhughes commented 2 years ago

Feels like the inconsistency highlighted in Tam's screenshots definitely ought to be resolved.

pjv commented 5 months ago

If you are shopping for use-cases, I can say that it would be extremely handy to be able to add order line items with negative quantities via the back end for certain customer service use cases.

A Woo shop I manage that has multiple sales channels in addition to Woo, but funnels all revenue and inventory accounting through Woo integrations with back end accounting and inventory management needs a simple way to reconcile situations involving mis-shipments and damaged shipments that require a transaction that can put items back into inventory as well as subtract from revenue already recognized. It’s not a refund because the original sale did not happen on the Woo shop. But creating a negative sale would be a simple transaction that experienced Woo shop managers could easily and quickly create that would solve all the bookkeeping issues in one go.