Skip to content

Commit

Permalink
feat: exclude cash on delivery payments from vendor withdrawal balance (
Browse files Browse the repository at this point in the history
#842)

* feat: exclude offline payments from vendor withdrawal balance

* refactor: only allow COD payment
  • Loading branch information
saimonh3 committed Jun 2, 2020
1 parent ef47218 commit 514381e
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
7 changes: 7 additions & 0 deletions includes/Admin/Settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,13 @@ public function get_settings_fields() {
'desc' => __( 'Minimum balance required to make a withdraw request. Leave blank to set no minimum limits.', 'dokan-lite' ),
'default' => '50',
'type' => 'text',
),
'exclude_cod_payment' => array(
'name' => 'exclude_cod_payment',
'label' => __( 'Exclude COD Payments', 'dokan-lite' ),
'desc' => __( 'If an order is paid with Cash on Delivery (COD), then exclude that payment from vendor balance.', 'dokan-lite' ),
'type' => 'checkbox',
'default' => 'off',
)
),
'dokan_pages' => array(
Expand Down
11 changes: 11 additions & 0 deletions includes/Order/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,17 @@ public function on_order_status_change( $order_id, $old_status, $new_status, $or
}
}

/**
* If `exclude_cod_payment` is enabled, don't include the fund in vendor's withdrawal balance.
*
* @since DOKAN_LITE_SINCE
*/
$exclude_cod_payment = 'on' === dokan_get_option( 'exclude_cod_payment', 'dokan_withdraw', 'off' );

if ( $exclude_cod_payment && 'cod' === $order->get_payment_method() ) {
return;
}

// update on vendor-balance table
$wpdb->update( $wpdb->prefix . 'dokan_vendor_balance',
array( 'status' => $new_status ),
Expand Down

0 comments on commit 514381e

Please sign in to comment.