getdokan/dokan

Stock Not Updating Correctly During Product Edit in Vendor Dashboard

Closed this issue · 1 comments

Bug Description

When a vendor edits a product in the Dokan vendor dashboard, the product's stock does not update correctly if sales occur while the vendor is editing. Specifically, the stock reverts to the original value that was loaded when the vendor opened the edit page, ignoring any sales that happened during the edit period.

Impact: This bug causes the stock quantity to be inaccurate, which can lead to overselling or mismanagement of inventory, impacting the overall store operations.

Step To Reproduce

  1. Go to the Dokan vendor dashboard.
  2. Click on "Edit" for any product with a stock quantity.
  3. While the edit page is open, have some sales occur on the product (reduce the stock by a few units).
  4. Without changing the stock quantity in the edit form, click "Save" to update the product.
  5. Check the product's stock quantity after saving.

Expected Behaviour

The stock quantity should be updated to reflect the sales that occurred while the vendor was editing the product. For example, if the stock was initially 100 and 5 units were sold during the editing process, the stock should update to 95 when the vendor saves the product.

Actual Behaviour

The stock quantity reverts to the original value that was loaded when the vendor first opened the edit page (e.g., 100), ignoring any sales that happened during the editing process. This results in an incorrect stock count.

Additional Information

  • There are no error messages shown, but the incorrect behavior can be consistently reproduced following the steps above.
  • I have implemented a workaround by adding a hidden field in the form that stores the original stock and comparing it before updating the stock. However, this does not prevent the stock from being updated by other functions or hooks in Dokan.

Environment (please complete the following information)

1. Dokan Version: v3.11.5
2. Dokan Pro Version: not applicable
3. WooCommerce Version: v9.1.4
4. Browser: (e.g., Chrome, Safari)
5. Current Theme: Hello Elementor

@mrabbani vai, please have a look at this.