Plugin Directory

Changeset 3439401


Ignore:
Timestamp:
01/14/2026 10:33:01 AM (8 weeks ago)
Author:
wedevs
Message:

Update to version 4.2.7 from GitHub

Location:
dokan-lite
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • dokan-lite/tags/4.2.7/dokan-class.php

    r3438499 r3439401  
    2626     * @var string
    2727     */
    28     public $version = '4.2.6';
     28    public $version = '4.2.7';
    2929
    3030    /**
  • dokan-lite/tags/4.2.7/dokan.php

    r3438499 r3439401  
    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/
  • dokan-lite/tags/4.2.7/includes/Order/Hooks.php

    r3288526 r3439401  
    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' ] );
    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 );
    6262    }
    6363
     
    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 ) {
     
    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
     
    450450
    451451    /**
    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    }
    534502}
  • dokan-lite/tags/4.2.7/languages/dokan-lite.pot

    r3438499 r3439401  
    22msgid ""
    33msgstr ""
    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"
     
    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"
     
    53275327msgstr ""
    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
  • dokan-lite/tags/4.2.7/readme.txt

    r3438499 r3439401  
    88WC tested up to: 10.4.3
    99Requires PHP: 7.4
    10 Stable tag: 4.2.6
     10Stable tag: 4.2.7
    1111License: GPLv2 or later
    1212License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    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.
     
    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).
  • dokan-lite/tags/4.2.7/templates/whats-new.php

    r3438499 r3439401  
    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',
  • dokan-lite/tags/4.2.7/vendor/composer/installed.php

    r3438499 r3439401  
    22    'root' => array(
    33        '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',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    3939        ),
    4040        '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',
    4444            'type' => 'wordpress-plugin',
    4545            'install_path' => __DIR__ . '/../../',
  • dokan-lite/trunk/dokan-class.php

    r3438499 r3439401  
    2626     * @var string
    2727     */
    28     public $version = '4.2.6';
     28    public $version = '4.2.7';
    2929
    3030    /**
  • dokan-lite/trunk/dokan.php

    r3438499 r3439401  
    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/
  • dokan-lite/trunk/includes/Order/Hooks.php

    r3288526 r3439401  
    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' ] );
    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 );
    6262    }
    6363
     
    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 ) {
     
    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
     
    450450
    451451    /**
    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 . '&rarr;' . $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    }
    534502}
  • dokan-lite/trunk/languages/dokan-lite.pot

    r3438499 r3439401  
    22msgid ""
    33msgstr ""
    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"
     
    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"
     
    53275327msgstr ""
    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
  • dokan-lite/trunk/readme.txt

    r3438499 r3439401  
    88WC tested up to: 10.4.3
    99Requires PHP: 7.4
    10 Stable tag: 4.2.6
     10Stable tag: 4.2.7
    1111License: GPLv2 or later
    1212License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    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.
     
    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).
  • dokan-lite/trunk/templates/whats-new.php

    r3438499 r3439401  
    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',
  • dokan-lite/trunk/vendor/composer/installed.php

    r3438499 r3439401  
    22    'root' => array(
    33        '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',
    77        'type' => 'wordpress-plugin',
    88        'install_path' => __DIR__ . '/../../',
     
    3939        ),
    4040        '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',
    4444            'type' => 'wordpress-plugin',
    4545            'install_path' => __DIR__ . '/../../',
Note: See TracChangeset for help on using the changeset viewer.