Bug Description
Summary
A single POST /wp-json/wc/v3/orders containing items from N vendors creates N×3 sub-orders instead of N. Three copies of WeDevs\Dokan\REST\OrderController (v1, v2, v3) each register the same hooks at rest_api_init, so WC fires the split callback three times per parent order.
Environment
Dokan Lite 5.0.3
Dokan Pro 5.0.2
WooCommerce 10.8.1
WordPress 7.0, HPOS enabled
Step To Reproduce
Multi-vendor setup with ≥2 vendors selling distinct products.
Generate a WC REST API key (write).
POST /wp-json/wc/v3/orders with line items from 2 vendors.
WooCommerce → Orders: parent created correctly, but 3 sub-orders per vendor appear (one from each controller version's callback).
Expected Behaviour
One sub-order per vendor.
Actual Behaviour
N×3 sub-orders per vendor (where 3 = the number of REST namespace versions Dokan registers).
Additional Information
Root cause
Each instantiation of OrderController (v1/v2/v3) hooks woocommerce_rest_pre_insert_shop_order_object (pre_insert_shop_order) and woocommerce_rest_insert_shop_order_object (after_order_create). WC fires those hooks once per POST, but they now have 3 callbacks each, all calling dokan()->order->maybe_split_orders() against the same parent.
Workaround
We patched with a mu-plugin that:
Removes the v1/v2/v3 controller callbacks at rest_api_init priority 11.
Re-registers a single guarded callback using add_option() as a transactional lock and an existing-children check before calling maybe_split_orders.
Repairs HPOS sub-order fields (parent_id, status, totals) that Dokan otherwise leaves stale after a REST-driven split.
Source available on request.
Suggested fix
Register the split hooks once in the REST Manager regardless of controller version. Alternatively, have OrderController::after_order_create early-return when the parent already has child orders or when a per-parent transient lock is set.
Environment (please complete the following information)
1. Dokan Version: [e.g. v3.1.2]
2. Dokan Pro Version: [e.g. v3.1.2]
3. WooCommerce Version: [e.g. v4.9.2]
4. Browser [e.g. chrome, safari]
5. Current Theme: [e.g. woodmart]
6. Wasil-app behavior only
Bug Description
Summary
A single POST /wp-json/wc/v3/orders containing items from N vendors creates N×3 sub-orders instead of N. Three copies of WeDevs\Dokan\REST\OrderController (v1, v2, v3) each register the same hooks at rest_api_init, so WC fires the split callback three times per parent order.
Environment
Dokan Lite 5.0.3
Dokan Pro 5.0.2
WooCommerce 10.8.1
WordPress 7.0, HPOS enabled
Step To Reproduce
Multi-vendor setup with ≥2 vendors selling distinct products.
Generate a WC REST API key (write).
POST /wp-json/wc/v3/orders with line items from 2 vendors.
WooCommerce → Orders: parent created correctly, but 3 sub-orders per vendor appear (one from each controller version's callback).
Expected Behaviour
One sub-order per vendor.
Actual Behaviour
N×3 sub-orders per vendor (where 3 = the number of REST namespace versions Dokan registers).
Additional Information
Root cause
Each instantiation of OrderController (v1/v2/v3) hooks woocommerce_rest_pre_insert_shop_order_object (pre_insert_shop_order) and woocommerce_rest_insert_shop_order_object (after_order_create). WC fires those hooks once per POST, but they now have 3 callbacks each, all calling dokan()->order->maybe_split_orders() against the same parent.
Workaround
We patched with a mu-plugin that:
Removes the v1/v2/v3 controller callbacks at rest_api_init priority 11.
Re-registers a single guarded callback using add_option() as a transactional lock and an existing-children check before calling maybe_split_orders.
Repairs HPOS sub-order fields (parent_id, status, totals) that Dokan otherwise leaves stale after a REST-driven split.
Source available on request.
Suggested fix
Register the split hooks once in the REST Manager regardless of controller version. Alternatively, have OrderController::after_order_create early-return when the parent already has child orders or when a per-parent transient lock is set.
Environment (please complete the following information)