Skip to content

Commit

Permalink
Fix withdraw create date, fix get withdraw request responses, charge …
Browse files Browse the repository at this point in the history
…amount when there is no charge
  • Loading branch information
Aunshon committed Nov 20, 2023
1 parent 602176d commit 52235e1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 9 deletions.
6 changes: 5 additions & 1 deletion assets/src/js/withdraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,8 @@
"select[name='withdraw_method'][id='withdraw-method'] option:selected"
).data();
let chargeAmount = 0;

let chargeText = '';

if ( chargeFixed ) {
chargeText += accounting.formatMoney( chargeFixed, dokan.currency );
chargeAmount += chargeFixed;
Expand All @@ -261,6 +261,10 @@
chargeText += ` = ${ accounting.formatMoney( chargeAmount ) }`;
}

if ( ! chargeText ) {
chargeText = accounting.formatMoney( chargeAmount, dokan.currency );
}

Dokan_Withdraw.showWithdrawChargeHtml( chargeText, chargeAmount, withdrawAmount );
},

Expand Down
4 changes: 2 additions & 2 deletions includes/Withdraw/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -243,9 +243,9 @@ public function has_pending_request( $user_id ) {
* @param integer $limit
* @param integer $offset
*
* @return array
* @return Withdraw[]
*/
public function get_withdraw_requests( $user_id = '', $status = 0, $limit = 10, $offset = 0 ) {
public function get_withdraw_requests( $user_id = '', $status = 0, $limit = 10, $offset = 0 ): array {
// get all function arguments as key => value pairs
$args = get_defined_vars();

Expand Down
11 changes: 11 additions & 0 deletions includes/Withdraw/Withdraw.php
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,17 @@ public function calculate_charge() {
return $this;
}

/**
* Returns withdraw data.
*
* @since DOKAN_SINCE
*
* @return array
*/
public function get_data(): array {
return $this->data;
}

/**
* Create or update a withdraw
*
Expand Down
14 changes: 8 additions & 6 deletions templates/withdraw/pending-request-listing.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
*
* @since 2.4
*
* @var $withdraw_requests WeDevs\Dokan\Withdraw\Withdraw[]
*
* @package dokan
*/

Expand All @@ -21,15 +23,15 @@
<?php foreach ( $withdraw_requests as $request ) : ?>

<tr>
<td><?php echo wp_kses_post( wc_price( $request->amount ) ); ?></td>
<td><?php echo esc_html( dokan_withdraw_get_method_title( $request->method, $request ) ); ?></td>
<td><?php echo esc_html( dokan_format_datetime( $request->date ) ); ?></td>
<td><?php echo wp_kses_post( wc_price( $request->get_amount() ) ); ?></td>
<td><?php echo esc_html( dokan_withdraw_get_method_title( $request->get_method(), $request->get_data() ) ); ?></td>
<td><?php echo esc_html( dokan_format_datetime( $request->get_date() ) ); ?></td>
<td>
<?php
$url = add_query_arg(
[
'dokan_handle_withdraw_request' => 'cancel',
'id' => $request->id,
'id' => $request->get_id(),
], dokan_get_navigation_url( 'withdraw-requests' )
);
?>
Expand All @@ -39,9 +41,9 @@
</td>
<td>
<?php
if ( $request->status === 0 ) {
if ( $request->get_status() === 0 ) {
echo '<span class="label label-danger">' . esc_html__( 'Pending Review', 'dokan-lite' ) . '</span>';
} elseif ( $request->status === 1 ) {
} elseif ( $request->get_status() === 1 ) {
echo '<span class="label label-warning">' . esc_html__( 'Accepted', 'dokan-lite' ) . '</span>';
}
?>
Expand Down

0 comments on commit 52235e1

Please sign in to comment.