Skip to content

Commit d4aeb17

Browse files
chore: Release version 4.2.7
Merge branch 'release/4.2.7'
2 parents 8a16417 + eb7bc5a commit d4aeb17

File tree

9 files changed

+61
-83
lines changed

9 files changed

+61
-83
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
### v4.2.7 ( Jan 14, 2026 ) ###
2+
- **fix:** Allow Dokan stock restoration on WC Block Checkout.
3+
14
### v4.2.6 ( Jan 13, 2026 ) ###
25
- **update:** Add brand fields in Vendor Product Creation Popup.
36
- **update:** Add address fields on customer account migration form.

dokan-class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ final class WeDevs_Dokan {
2525
*
2626
* @var string
2727
*/
28-
public $version = '4.2.6';
28+
public $version = '4.2.7';
2929

3030
/**
3131
* Instance of self

dokan.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Dokan
44
* Plugin URI: https://dokan.co/wordpress/
55
* Description: An e-commerce marketplace plugin for WordPress. Powered by WooCommerce and weDevs.
6-
* Version: 4.2.6
6+
* Version: 4.2.7
77
* Author: Dokan Inc.
88
* Author URI: https://dokan.co/wordpress/
99
* Text Domain: dokan-lite

includes/Order/Hooks.php

Lines changed: 35 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,10 @@ public function __construct() {
5555
add_action( 'woocommerce_process_shop_order_meta', 'dokan_sync_insert_order', 60 );
5656
}
5757

58-
// restore order stock if it's been reduced by twice
59-
add_action( 'woocommerce_reduce_order_stock', [ $this, 'restore_reduced_order_stock' ] );
58+
// prevent stock reduction for parent orders
59+
add_filter( 'woocommerce_can_reduce_order_stock', [ $this, 'prevent_stock_reduction_for_parent_order' ], 10, 2 );
6060

61-
add_action( 'woocommerce_reduce_order_stock', [ $this, 'handle_order_notes_for_suborder' ], 99 );
61+
add_action( 'woocommerce_reduce_order_item_stock', [ $this, 'sync_parent_order_item_stock' ], 10, 3 );
6262
}
6363

6464
/**
@@ -420,14 +420,14 @@ public function split_vendor_orders( $parent_order_id ) {
420420
* @throws Exception When the coupon is invalid for multiple vendors
421421
*/
422422
public function ensure_coupon_is_valid( bool $valid, WC_Coupon $coupon, WC_Discounts $discounts ): bool {
423-
$available_vendors = [];
423+
$available_vendors = [];
424424

425425
foreach ( $discounts->get_items() as $item ) {
426426
if ( ! isset( $item->product ) || ! $item->product instanceof WC_Product ) {
427427
continue;
428428
}
429429

430-
$available_vendors[] = (int) dokan_get_vendor_by_product( $item->product->get_id(), true );
430+
$available_vendors[] = (int) dokan_get_vendor_by_product( $item->product->get_id(), true );
431431
}
432432

433433
$available_vendors = array_unique( $available_vendors );
@@ -449,86 +449,54 @@ public function ensure_coupon_is_valid( bool $valid, WC_Coupon $coupon, WC_Disco
449449
}
450450

451451
/**
452-
* Restore order stock if it's been reduced by twice
452+
* Prevent stock reduction for parent orders
453453
*
454-
* @param WC_Order $order
454+
* Parent orders should not have their stock reduced. Only sub-orders
455+
* should manage stock reductions.
455456
*
456-
* @return void
457+
* @param bool $can_reduce Whether stock can be reduced.
458+
* @param WC_Order $order The order object.
459+
*
460+
* @return bool False if this is a parent order, true otherwise.
457461
*/
458-
public function restore_reduced_order_stock( $order ) {
459-
// seems in rest request, there is no such issue like (stock reduced by twice), so return early
460-
if ( defined( 'REST_REQUEST' ) ) {
461-
return;
462+
public function prevent_stock_reduction_for_parent_order( $can_reduce, $order ) {
463+
// If this is a parent order (has sub-orders), prevent stock reduction
464+
if ( $order->get_meta( 'has_sub_order' ) ) {
465+
return false;
462466
}
463467

464-
// seems it's not a parent order so return early
465-
if ( ! $order->get_meta( 'has_sub_order' ) ) {
466-
return;
467-
}
468-
469-
// Loop over all items.
470-
foreach ( $order->get_items( 'line_item' ) as $item ) {
471-
// Only reduce stock once for each item.
472-
$product = $item->get_product();
473-
$item_stock_reduced = $item->get_meta( '_reduced_stock', true );
474-
475-
if ( ! $item_stock_reduced || ! $product || ! $product->managing_stock() ) {
476-
continue;
477-
}
478-
479-
$item_name = $product->get_formatted_name();
480-
$new_stock = wc_update_product_stock( $product, $item_stock_reduced, 'increase' );
481-
482-
if ( is_wp_error( $new_stock ) ) {
483-
/* translators: %s item name. */
484-
$order->add_order_note( sprintf( __( 'Unable to restore stock for item %s.', 'dokan-lite' ), $item_name ) );
485-
continue;
486-
}
487-
488-
$item->delete_meta_data( '_reduced_stock' );
489-
$item->save();
490-
}
468+
return $can_reduce;
491469
}
492470

493471
/**
494-
* Handle stock level wrong calculation in order notes for suborder
472+
* Sync parent order item stock metadata when sub-order item stock is reduced
495473
*
496-
* @since 3.8.3
497-
*
498-
* @param WC_Order $order
474+
* When a sub-order item has its stock reduced, also update the parent order item's
475+
* _reduced_stock metadata to keep them in sync.
476+
* @param WC_Order_Item_Product $item The sub-order item.
477+
* @param array $change Change details (product, from, to).
478+
* @param WC_Order $order The sub-order.
499479
*
500480
* @return void
501481
*/
502-
public function handle_order_notes_for_suborder( $order ) {
503-
//return if it has suborder. only continue if this is a suborder
504-
if ( ! $order->get_meta( 'has_sub_order' ) ) {
482+
public function sync_parent_order_item_stock( $item, $change, $order ) {
483+
// Only process sub-orders (those with a parent)
484+
if ( ! $order->get_parent_id() ) {
505485
return;
506486
}
507487

508-
$notes = wc_get_order_notes( [ 'order_id' => $order->get_id() ] );
488+
// Get the parent order item ID from the sub-order item meta
489+
$parent_item_id = $item->get_meta( '_dokan_parent_order_item_id', true );
509490

510-
//change stock level note status instead of deleting
511-
foreach ( $notes as $note ) {
512-
//here using the woocommerce as text domain because we are using woocommerce text for searching
513-
if ( false !== strpos( $note->content, __( 'Stock levels reduced:', 'woocommerce' ) ) ) { //phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
514-
//update notes status to `hold`, so that it will not show in order details page
515-
wp_set_comment_status( $note->id, 'hold' );
516-
}
491+
if ( ! $parent_item_id ) {
492+
return;
517493
}
518494

519-
//adding stock level notes in order
520-
foreach ( $order->get_items( 'line_item' ) as $key => $line_item ) {
521-
$product = $line_item->get_product();
522-
523-
if ( $product->get_manage_stock() ) {
524-
$stock_quantity = $product->get_stock_quantity();
525-
$previous_quantity = (int) $stock_quantity + $line_item->get_quantity();
526-
527-
$notes_content = $product->get_formatted_name() . ' ' . $previous_quantity . '→' . $stock_quantity;
495+
$reduced_qty = $item->get_meta( '_reduced_stock', true );
528496

529-
//here using the woocommerce as text domain because we are using woocommerce text for adding
530-
$order->add_order_note( __( 'Stock levels reduced:', 'woocommerce' ) . ' ' . $notes_content ); //phpcs:ignore WordPress.WP.I18n.TextDomainMismatch
531-
}
497+
// Update the parent item directly in the database
498+
if ( $reduced_qty ) {
499+
wc_update_order_item_meta( $parent_item_id, '_reduced_stock', $reduced_qty );
532500
}
533-
}
501+
}
534502
}

languages/dokan-lite.pot

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Copyright (c) 2026 Dokan Inc. All Rights Reserved.
22
msgid ""
33
msgstr ""
4-
"Project-Id-Version: Dokan 4.2.6\n"
4+
"Project-Id-Version: Dokan 4.2.7\n"
55
"Report-Msgid-Bugs-To: https://dokan.co/contact/\n"
66
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
77
"Language-Team: LANGUAGE <[email protected]>\n"
88
"MIME-Version: 1.0\n"
99
"Content-Type: text/plain; charset=UTF-8\n"
1010
"Content-Transfer-Encoding: 8bit\n"
11-
"POT-Creation-Date: 2026-01-13T06:38:55+00:00\n"
11+
"POT-Creation-Date: 2026-01-14T10:18:42+00:00\n"
1212
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
1313
"X-Generator: WP-CLI 2.11.0\n"
1414
"X-Domain: dokan-lite\n"
@@ -5326,11 +5326,6 @@ msgstr ""
53265326
msgid "This coupon is invalid for multiple vendors."
53275327
msgstr ""
53285328

5329-
#. translators: %s item name.
5330-
#: includes/Order/Hooks.php:484
5331-
msgid "Unable to restore stock for item %s."
5332-
msgstr ""
5333-
53345329
#. translators: 1: Order ID, 2: Refund ID, 3: Refund Amount
53355330
#: includes/Order/RefundHandler.php:192
53365331
msgid "Dokan refund adjustment error: Seller not found, Order ID: %1$d, Refund ID: %2$d, Refund Amount: %3$f "

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "dokan",
3-
"version": "4.2.6",
3+
"version": "4.2.7",
44
"description": "A WordPress marketplace plugin",
55
"author": "Dokan Inc.",
66
"license": "GPL",

readme.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Tested up to: 6.9
77
WC requires at least: 8.5.0
88
WC tested up to: 10.4.3
99
Requires PHP: 7.4
10-
Stable tag: 4.2.6
10+
Stable tag: 4.2.7
1111
License: GPLv2 or later
1212
License URI: http://www.gnu.org/licenses/gpl-2.0.html
1313

@@ -353,6 +353,9 @@ A. Just install and activate the PRO version without deleting the free plugin. A
353353

354354
== Changelog ==
355355

356+
= v4.2.7 ( Jan 14, 2026 ) =
357+
- **fix:** Allow Dokan stock restoration on WC Block Checkout.
358+
356359
= v4.2.6 ( Jan 13, 2026 ) =
357360
- **update:** Add brand fields in Vendor Product Creation Popup.
358361
- **update:** Add address fields on customer account migration form.
@@ -375,7 +378,4 @@ A. Just install and activate the PRO version without deleting the free plugin. A
375378
= v4.2.3 ( Dec 22, 2025 ) =
376379
- **fix:** Compatible vendor store banner image cropper with the latest version.
377380

378-
= v4.2.2 ( Dec 22, 2025 ) =
379-
- **fix:** Banner image cropper reflects an error on the vendor store settings.
380-
381381
[See changelog for all versions](https://github.com/getdokan/dokan/blob/develop/CHANGELOG.md).

templates/whats-new.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,18 @@
33
* When you are adding new version please follow this sequence for changes: New Feature, New, Improvement, Fix...
44
*/
55
$changelog = [
6+
[
7+
'version' => 'Version 4.2.7',
8+
'released' => '2026-01-14',
9+
'changes' => [
10+
'Fix' => [
11+
[
12+
'title' => 'Allow Dokan stock restoration on WC Block Checkout.',
13+
'description' => '',
14+
],
15+
],
16+
],
17+
],
618
[
719
'version' => 'Version 4.2.6',
820
'released' => '2026-01-13',

0 commit comments

Comments
 (0)