Changeset 3439401
- Timestamp:
- 01/14/2026 10:33:01 AM (8 weeks ago)
- Location:
- dokan-lite
- Files:
-
- 14 edited
- 1 copied
-
tags/4.2.7 (copied) (copied from dokan-lite/trunk)
-
tags/4.2.7/dokan-class.php (modified) (1 diff)
-
tags/4.2.7/dokan.php (modified) (1 diff)
-
tags/4.2.7/includes/Order/Hooks.php (modified) (4 diffs)
-
tags/4.2.7/languages/dokan-lite.pot (modified) (3 diffs)
-
tags/4.2.7/readme.txt (modified) (3 diffs)
-
tags/4.2.7/templates/whats-new.php (modified) (1 diff)
-
tags/4.2.7/vendor/composer/installed.php (modified) (2 diffs)
-
trunk/dokan-class.php (modified) (1 diff)
-
trunk/dokan.php (modified) (1 diff)
-
trunk/includes/Order/Hooks.php (modified) (4 diffs)
-
trunk/languages/dokan-lite.pot (modified) (3 diffs)
-
trunk/readme.txt (modified) (3 diffs)
-
trunk/templates/whats-new.php (modified) (1 diff)
-
trunk/vendor/composer/installed.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
dokan-lite/tags/4.2.7/dokan-class.php
r3438499 r3439401 26 26 * @var string 27 27 */ 28 public $version = '4.2. 6';28 public $version = '4.2.7'; 29 29 30 30 /** -
dokan-lite/tags/4.2.7/dokan.php
r3438499 r3439401 4 4 * Plugin URI: https://dokan.co/wordpress/ 5 5 * Description: An e-commerce marketplace plugin for WordPress. Powered by WooCommerce and weDevs. 6 * Version: 4.2. 66 * Version: 4.2.7 7 7 * Author: Dokan Inc. 8 8 * Author URI: https://dokan.co/wordpress/ -
dokan-lite/tags/4.2.7/includes/Order/Hooks.php
r3288526 r3439401 56 56 } 57 57 58 // restore order stock if it's been reduced by twice59 add_ action( 'woocommerce_reduce_order_stock', [ $this, 'restore_reduced_order_stock' ]);60 61 add_action( 'woocommerce_reduce_order_ stock', [ $this, 'handle_order_notes_for_suborder' ], 99);58 // prevent stock reduction for parent orders 59 add_filter( 'woocommerce_can_reduce_order_stock', [ $this, 'prevent_stock_reduction_for_parent_order' ], 10, 2 ); 60 61 add_action( 'woocommerce_reduce_order_item_stock', [ $this, 'sync_parent_order_item_stock' ], 10, 3 ); 62 62 } 63 63 … … 421 421 */ 422 422 public function ensure_coupon_is_valid( bool $valid, WC_Coupon $coupon, WC_Discounts $discounts ): bool { 423 $available_vendors = [];423 $available_vendors = []; 424 424 425 425 foreach ( $discounts->get_items() as $item ) { … … 428 428 } 429 429 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 ); 431 431 } 432 432 … … 450 450 451 451 /** 452 * Restore order stock if it's been reduced by twice 453 * 454 * @param WC_Order $order 455 * 456 * @return void 457 */ 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 } 463 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 } 491 } 492 493 /** 494 * Handle stock level wrong calculation in order notes for suborder 495 * 496 * @since 3.8.3 497 * 498 * @param WC_Order $order 499 * 500 * @return void 501 */ 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' ) ) { 505 return; 506 } 507 508 $notes = wc_get_order_notes( [ 'order_id' => $order->get_id() ] ); 509 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 } 517 } 518 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; 528 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 } 532 } 533 } 452 * Prevent stock reduction for parent orders 453 * 454 * Parent orders should not have their stock reduced. Only sub-orders 455 * should manage stock reductions. 456 * 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. 461 */ 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; 466 } 467 468 return $can_reduce; 469 } 470 471 /** 472 * Sync parent order item stock metadata when sub-order item stock is reduced 473 * 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. 479 * 480 * @return void 481 */ 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() ) { 485 return; 486 } 487 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 ); 490 491 if ( ! $parent_item_id ) { 492 return; 493 } 494 495 $reduced_qty = $item->get_meta( '_reduced_stock', true ); 496 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 ); 500 } 501 } 534 502 } -
dokan-lite/tags/4.2.7/languages/dokan-lite.pot
r3438499 r3439401 2 2 msgid "" 3 3 msgstr "" 4 "Project-Id-Version: Dokan 4.2. 6\n"4 "Project-Id-Version: Dokan 4.2.7\n" 5 5 "Report-Msgid-Bugs-To: https://dokan.co/contact/\n" 6 6 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 9 9 "Content-Type: text/plain; charset=UTF-8\n" 10 10 "Content-Transfer-Encoding: 8bit\n" 11 "POT-Creation-Date: 2026-01-1 3T06:38:55+00:00\n"11 "POT-Creation-Date: 2026-01-14T10:18:42+00:00\n" 12 12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 13 "X-Generator: WP-CLI 2.11.0\n" … … 5327 5327 msgstr "" 5328 5328 5329 #. translators: %s item name.5330 #: includes/Order/Hooks.php:4845331 msgid "Unable to restore stock for item %s."5332 msgstr ""5333 5334 5329 #. translators: 1: Order ID, 2: Refund ID, 3: Refund Amount 5335 5330 #: includes/Order/RefundHandler.php:192 -
dokan-lite/tags/4.2.7/readme.txt
r3438499 r3439401 8 8 WC tested up to: 10.4.3 9 9 Requires PHP: 7.4 10 Stable tag: 4.2. 610 Stable tag: 4.2.7 11 11 License: GPLv2 or later 12 12 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 354 354 == Changelog == 355 355 356 = v4.2.7 ( Jan 14, 2026 ) = 357 - **fix:** Allow Dokan stock restoration on WC Block Checkout. 358 356 359 = v4.2.6 ( Jan 13, 2026 ) = 357 360 - **update:** Add brand fields in Vendor Product Creation Popup. … … 376 379 - **fix:** Compatible vendor store banner image cropper with the latest version. 377 380 378 = v4.2.2 ( Dec 22, 2025 ) =379 - **fix:** Banner image cropper reflects an error on the vendor store settings.380 381 381 [See changelog for all versions](https://github.com/getdokan/dokan/blob/develop/CHANGELOG.md). -
dokan-lite/tags/4.2.7/templates/whats-new.php
r3438499 r3439401 4 4 */ 5 5 $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 ], 6 18 [ 7 19 'version' => 'Version 4.2.6', -
dokan-lite/tags/4.2.7/vendor/composer/installed.php
r3438499 r3439401 2 2 'root' => array( 3 3 'name' => 'wedevs/dokan', 4 'pretty_version' => 'v4.2. 6',5 'version' => '4.2. 6.0',6 'reference' => ' 8a16417d7cf8987f6677ad96f2e5454fe807acbe',4 'pretty_version' => 'v4.2.7', 5 'version' => '4.2.7.0', 6 'reference' => 'd4aeb17c81539d14fc1e519663ae23b64c8591e1', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 39 39 ), 40 40 'wedevs/dokan' => array( 41 'pretty_version' => 'v4.2. 6',42 'version' => '4.2. 6.0',43 'reference' => ' 8a16417d7cf8987f6677ad96f2e5454fe807acbe',41 'pretty_version' => 'v4.2.7', 42 'version' => '4.2.7.0', 43 'reference' => 'd4aeb17c81539d14fc1e519663ae23b64c8591e1', 44 44 'type' => 'wordpress-plugin', 45 45 'install_path' => __DIR__ . '/../../', -
dokan-lite/trunk/dokan-class.php
r3438499 r3439401 26 26 * @var string 27 27 */ 28 public $version = '4.2. 6';28 public $version = '4.2.7'; 29 29 30 30 /** -
dokan-lite/trunk/dokan.php
r3438499 r3439401 4 4 * Plugin URI: https://dokan.co/wordpress/ 5 5 * Description: An e-commerce marketplace plugin for WordPress. Powered by WooCommerce and weDevs. 6 * Version: 4.2. 66 * Version: 4.2.7 7 7 * Author: Dokan Inc. 8 8 * Author URI: https://dokan.co/wordpress/ -
dokan-lite/trunk/includes/Order/Hooks.php
r3288526 r3439401 56 56 } 57 57 58 // restore order stock if it's been reduced by twice59 add_ action( 'woocommerce_reduce_order_stock', [ $this, 'restore_reduced_order_stock' ]);60 61 add_action( 'woocommerce_reduce_order_ stock', [ $this, 'handle_order_notes_for_suborder' ], 99);58 // prevent stock reduction for parent orders 59 add_filter( 'woocommerce_can_reduce_order_stock', [ $this, 'prevent_stock_reduction_for_parent_order' ], 10, 2 ); 60 61 add_action( 'woocommerce_reduce_order_item_stock', [ $this, 'sync_parent_order_item_stock' ], 10, 3 ); 62 62 } 63 63 … … 421 421 */ 422 422 public function ensure_coupon_is_valid( bool $valid, WC_Coupon $coupon, WC_Discounts $discounts ): bool { 423 $available_vendors = [];423 $available_vendors = []; 424 424 425 425 foreach ( $discounts->get_items() as $item ) { … … 428 428 } 429 429 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 ); 431 431 } 432 432 … … 450 450 451 451 /** 452 * Restore order stock if it's been reduced by twice 453 * 454 * @param WC_Order $order 455 * 456 * @return void 457 */ 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 } 463 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 } 491 } 492 493 /** 494 * Handle stock level wrong calculation in order notes for suborder 495 * 496 * @since 3.8.3 497 * 498 * @param WC_Order $order 499 * 500 * @return void 501 */ 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' ) ) { 505 return; 506 } 507 508 $notes = wc_get_order_notes( [ 'order_id' => $order->get_id() ] ); 509 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 } 517 } 518 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; 528 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 } 532 } 533 } 452 * Prevent stock reduction for parent orders 453 * 454 * Parent orders should not have their stock reduced. Only sub-orders 455 * should manage stock reductions. 456 * 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. 461 */ 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; 466 } 467 468 return $can_reduce; 469 } 470 471 /** 472 * Sync parent order item stock metadata when sub-order item stock is reduced 473 * 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. 479 * 480 * @return void 481 */ 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() ) { 485 return; 486 } 487 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 ); 490 491 if ( ! $parent_item_id ) { 492 return; 493 } 494 495 $reduced_qty = $item->get_meta( '_reduced_stock', true ); 496 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 ); 500 } 501 } 534 502 } -
dokan-lite/trunk/languages/dokan-lite.pot
r3438499 r3439401 2 2 msgid "" 3 3 msgstr "" 4 "Project-Id-Version: Dokan 4.2. 6\n"4 "Project-Id-Version: Dokan 4.2.7\n" 5 5 "Report-Msgid-Bugs-To: https://dokan.co/contact/\n" 6 6 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" … … 9 9 "Content-Type: text/plain; charset=UTF-8\n" 10 10 "Content-Transfer-Encoding: 8bit\n" 11 "POT-Creation-Date: 2026-01-1 3T06:38:55+00:00\n"11 "POT-Creation-Date: 2026-01-14T10:18:42+00:00\n" 12 12 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" 13 13 "X-Generator: WP-CLI 2.11.0\n" … … 5327 5327 msgstr "" 5328 5328 5329 #. translators: %s item name.5330 #: includes/Order/Hooks.php:4845331 msgid "Unable to restore stock for item %s."5332 msgstr ""5333 5334 5329 #. translators: 1: Order ID, 2: Refund ID, 3: Refund Amount 5335 5330 #: includes/Order/RefundHandler.php:192 -
dokan-lite/trunk/readme.txt
r3438499 r3439401 8 8 WC tested up to: 10.4.3 9 9 Requires PHP: 7.4 10 Stable tag: 4.2. 610 Stable tag: 4.2.7 11 11 License: GPLv2 or later 12 12 License URI: http://www.gnu.org/licenses/gpl-2.0.html … … 354 354 == Changelog == 355 355 356 = v4.2.7 ( Jan 14, 2026 ) = 357 - **fix:** Allow Dokan stock restoration on WC Block Checkout. 358 356 359 = v4.2.6 ( Jan 13, 2026 ) = 357 360 - **update:** Add brand fields in Vendor Product Creation Popup. … … 376 379 - **fix:** Compatible vendor store banner image cropper with the latest version. 377 380 378 = v4.2.2 ( Dec 22, 2025 ) =379 - **fix:** Banner image cropper reflects an error on the vendor store settings.380 381 381 [See changelog for all versions](https://github.com/getdokan/dokan/blob/develop/CHANGELOG.md). -
dokan-lite/trunk/templates/whats-new.php
r3438499 r3439401 4 4 */ 5 5 $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 ], 6 18 [ 7 19 'version' => 'Version 4.2.6', -
dokan-lite/trunk/vendor/composer/installed.php
r3438499 r3439401 2 2 'root' => array( 3 3 'name' => 'wedevs/dokan', 4 'pretty_version' => 'v4.2. 6',5 'version' => '4.2. 6.0',6 'reference' => ' 8a16417d7cf8987f6677ad96f2e5454fe807acbe',4 'pretty_version' => 'v4.2.7', 5 'version' => '4.2.7.0', 6 'reference' => 'd4aeb17c81539d14fc1e519663ae23b64c8591e1', 7 7 'type' => 'wordpress-plugin', 8 8 'install_path' => __DIR__ . '/../../', … … 39 39 ), 40 40 'wedevs/dokan' => array( 41 'pretty_version' => 'v4.2. 6',42 'version' => '4.2. 6.0',43 'reference' => ' 8a16417d7cf8987f6677ad96f2e5454fe807acbe',41 'pretty_version' => 'v4.2.7', 42 'version' => '4.2.7.0', 43 'reference' => 'd4aeb17c81539d14fc1e519663ae23b64c8591e1', 44 44 'type' => 'wordpress-plugin', 45 45 'install_path' => __DIR__ . '/../../',
Note: See TracChangeset
for help on using the changeset viewer.