-
Notifications
You must be signed in to change notification settings - Fork 213
Fix: exclude POS cash orders from vendor withdrawable balance #3079
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
5aef129
ebed238
6d6224f
b6b7d1c
86b25b2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,7 +19,7 @@ | |
| add_filter( 'dokan_refund_should_insert_into_vendor_balance', [ $this, 'exclude_cod_payment' ], 10, 3 ); | ||
| add_filter( 'dokan_vendor_earning_in_refund', [ $this, 'get_vendor_earning_in_refund' ], 10, 2 ); | ||
| add_action( 'dokan_refund_adjust_vendor_balance', [ $this, 'insert_into_balance_table' ], 10, 3 ); | ||
| // add_action( 'dokan_refund_adjust_dokan_orders', [ $this, 'update_order_amounts' ], 10, 3 ); | ||
| add_action( 'dokan_refund_after_dokan_orders_updated', [ $this, 'clear_order_caches' ], 10, 3 ); | ||
| } | ||
|
|
||
|
|
@@ -87,25 +87,41 @@ | |
| * @param bool $ret | ||
| * @param \WC_Order_Refund $refund_order | ||
| * @param \WC_Order $order | ||
| * @return bool | ||
| * @return bool | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
| */ | ||
| public function exclude_cod_payment( $ret, $refund_order, $order ) { | ||
| // return if $order is not an instance of WC_Order | ||
| if ( ! $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(); | ||
| /** | ||
|
Shamim-97 marked this conversation as resolved.
Outdated
|
||
| * 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. | ||
| */ | ||
|
Shamim-97 marked this conversation as resolved.
|
||
| $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, | ||
| ); | ||
|
Comment on lines
+108
to
+128
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Docblock type mismatch for Line 117 documents Also, ensure the 📝 Proposed fix * `@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 Whether the 'exclude COD' setting is enabled.
* `@param` WC_Order $refund_order The specific refund order object.
*/🤖 Prompt for AI Agents |
||
|
|
||
| if ( $exclude_cod_payment ) { | ||
| if ( $should_exclude_cod_payment ) { | ||
| return false; | ||
| } | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.