From 5aef129588d549d8e07350f6c9980a9e87f2ce56 Mon Sep 17 00:00:00 2001 From: SHAMIM <111671483+Shamim-97@users.noreply.github.com> Date: Mon, 19 Jan 2026 12:45:29 +0600 Subject: [PATCH 1/5] Fix: exclude POS cash orders from vendor withdrawable balance --- includes/Order/Hooks.php | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/includes/Order/Hooks.php b/includes/Order/Hooks.php index 1841244af6..bf6c2fac5b 100644 --- a/includes/Order/Hooks.php +++ b/includes/Order/Hooks.php @@ -123,7 +123,29 @@ public function on_order_status_change( $order_id, $old_status, $new_status, $or */ $exclude_cod_payment = 'on' === dokan_get_option( 'exclude_cod_payment', 'dokan_withdraw', 'off' ); - if ( $exclude_cod_payment && 'cod' === $order->get_payment_method() ) { + $should_exclude_cod_payment = $exclude_cod_payment && 'cod' === $order->get_payment_method(); + + /** + * Filter whether the order should be excluded from vendor withdrawal balance. + * + * @since DOKAN_SINCE + * + * @param bool $should_exclude_cod_payment Whether to exclude COD payment from balance. + * @param WC_Order $order Order object. + * @param int $order_id Order ID. + * @param string $new_status New order status. + * @param bool $exclude_cod_payment Whether exclude COD option is enabled. + */ + $should_exclude_cod_payment = apply_filters( + 'dokan_order_should_exclude_from_vendor_balance', + $should_exclude_cod_payment, + $order, + $order_id, + $new_status, + $exclude_cod_payment + ); + + if ( $should_exclude_cod_payment ) { return; } From ebed23883a350869331c0c9789416b68a3608929 Mon Sep 17 00:00:00 2001 From: SHAMIM <111671483+Shamim-97@users.noreply.github.com> Date: Mon, 19 Jan 2026 18:02:23 +0600 Subject: [PATCH 2/5] fix: exclude wepos_cash payments from vendor balance adjustment on refund --- includes/Order/RefundHandler.php | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) diff --git a/includes/Order/RefundHandler.php b/includes/Order/RefundHandler.php index 6b78da39e5..77e210a643 100644 --- a/includes/Order/RefundHandler.php +++ b/includes/Order/RefundHandler.php @@ -87,7 +87,7 @@ public function get_vendor_earning_in_refund( $refund_order, $order ): float { * @param bool $ret * @param \WC_Order_Refund $refund_order * @param \WC_Order $order - * @return bool + * @return bool */ public function exclude_cod_payment( $ret, $refund_order, $order ) { // return if $order is not an instance of WC_Order @@ -95,17 +95,33 @@ public function exclude_cod_payment( $ret, $refund_order, $order ) { return $ret; } - // if cod is not payment method return - if ( 'cod' !== $order->get_payment_method() ) { - return $ret; - } + $order_id = $order->get_id(); + $new_status = $order->get_status(); + /** + * Get the base setting from Dokan options + */ + $exclude_cod_option = 'on' === dokan_get_option( 'exclude_cod_payment', 'dokan_withdraw', 'off' ); /** - * If `exclude_cod_payment` is enabled, don't include the fund in vendor's refund balance. + * Calculate the default logic (Is it COD and is the option ON?) */ - $exclude_cod_payment = 'on' === dokan_get_option( 'exclude_cod_payment', 'dokan_withdraw', 'off' ); + $should_exclude_cod_payment = $exclude_cod_option && 'cod' === $order->get_payment_method(); + + /** + * Apply the filter so other plugins (like wePOS) can override this. + * Use the exact same filter name for consistency across the whole system. + */ + $should_exclude_cod_payment = apply_filters( + 'dokan_order_refund_should_exclude_from_vendor_balance', + $should_exclude_cod_payment, + $order, + $order_id, + $new_status, + $exclude_cod_option, + $refund_order, + ); - if ( $exclude_cod_payment ) { + if ( $should_exclude_cod_payment ) { return false; } From 6d6224fed8cedd89498a0911f7c7cd998d188c92 Mon Sep 17 00:00:00 2001 From: SHAMIM <111671483+Shamim-97@users.noreply.github.com> Date: Mon, 19 Jan 2026 18:05:13 +0600 Subject: [PATCH 3/5] fix: exclude wepos_cash payments from vendor balance adjustment on refund --- includes/Order/RefundHandler.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/Order/RefundHandler.php b/includes/Order/RefundHandler.php index 77e210a643..94f5d57ac0 100644 --- a/includes/Order/RefundHandler.php +++ b/includes/Order/RefundHandler.php @@ -87,7 +87,7 @@ public function get_vendor_earning_in_refund( $refund_order, $order ): float { * @param bool $ret * @param \WC_Order_Refund $refund_order * @param \WC_Order $order - * @return bool + * @return bool */ public function exclude_cod_payment( $ret, $refund_order, $order ) { // return if $order is not an instance of WC_Order From b6b7d1cdc51ff76a92a8b004ac950861924b00e0 Mon Sep 17 00:00:00 2001 From: SHAMIM <111671483+Shamim-97@users.noreply.github.com> Date: Fri, 23 Jan 2026 09:17:07 +0600 Subject: [PATCH 4/5] Docs: Enrich DocBlock for vendor balance refund filter --- includes/Order/RefundHandler.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/includes/Order/RefundHandler.php b/includes/Order/RefundHandler.php index 94f5d57ac0..d1a30529ce 100644 --- a/includes/Order/RefundHandler.php +++ b/includes/Order/RefundHandler.php @@ -97,9 +97,7 @@ public function exclude_cod_payment( $ret, $refund_order, $order ) { $order_id = $order->get_id(); $new_status = $order->get_status(); - /** - * Get the base setting from Dokan options - */ + $exclude_cod_option = 'on' === dokan_get_option( 'exclude_cod_payment', 'dokan_withdraw', 'off' ); /** @@ -110,6 +108,14 @@ public function exclude_cod_payment( $ret, $refund_order, $order ) { /** * Apply the filter so other plugins (like wePOS) can override this. * Use the exact same filter name for consistency across the whole system. + * + * @since DOKAN_SINCE + * @param bool $should_exclude_cod_payment Whether to exclude the payment. + * @param WC_Order $order The main WooCommerce order object. + * @param int $order_id The ID of the main order. + * @param string $new_status The new status of the order. + * @param string $exclude_cod_option The value of the 'exclude COD' setting. + * @param WC_Order $refund_order The specific refund order object. */ $should_exclude_cod_payment = apply_filters( 'dokan_order_refund_should_exclude_from_vendor_balance', From 86b25b2294fb59b2444b66b47e8fb0d6115f84b4 Mon Sep 17 00:00:00 2001 From: SHAMIM <111671483+Shamim-97@users.noreply.github.com> Date: Tue, 27 Jan 2026 14:11:59 +0600 Subject: [PATCH 5/5] Docs: Enrich DocBlock for vendor balance refund filter --- includes/Order/RefundHandler.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/Order/RefundHandler.php b/includes/Order/RefundHandler.php index d1a30529ce..dd60866e50 100644 --- a/includes/Order/RefundHandler.php +++ b/includes/Order/RefundHandler.php @@ -108,13 +108,13 @@ public function exclude_cod_payment( $ret, $refund_order, $order ) { /** * Apply the filter so other plugins (like wePOS) can override this. * Use the exact same filter name for consistency across the whole system. - * + * * @since DOKAN_SINCE * @param bool $should_exclude_cod_payment Whether to exclude the payment. * @param WC_Order $order The main WooCommerce order object. * @param int $order_id The ID of the main order. * @param string $new_status The new status of the order. - * @param string $exclude_cod_option The value of the 'exclude COD' setting. + * @param bool $exclude_cod_option The value of the 'exclude COD' setting. * @param WC_Order $refund_order The specific refund order object. */ $should_exclude_cod_payment = apply_filters(