$req_success = isset( $get_data['message'] ) ? true : false; if ( ! $req_success ) { $message = sprintf( '
%s
%s
', __( 'You already have pending withdraw request(s).', 'dokan-lite' ), __( 'Please submit your request after approval or cancellation of your previous request.', 'dokan-lite' ) ); $this->show_error_messages( $message ); } $this->withdraw_requests( $current_user->ID ); return; } else if ( ! dokan()->withdraw->has_withdraw_balance( $current_user->ID ) ) { $message = __( 'You don\'t have sufficient balance for a withdraw request!', 'dokan-lite' ); $this->show_error_messages( $message ); return; } $payment_methods = array_intersect( dokan_get_seller_active_withdraw_methods(), dokan_withdraw_get_active_methods() ); $amount = ''; $withdraw_method = ''; dokan_get_template_part( 'withdraw/request-form', '', array( 'amount' => $amount, 'withdraw_method' => $withdraw_method, 'payment_methods' => $payment_methods, ) ); } /** * Get all withdraws * * @param integer $user_id [description] * * @return [type] [description] */ public function get_all_withdraws( $user_id, $limit = 100, $offset = 0 ) { if ( ! current_user_can( 'dokan_manage_withdraw' ) ) { return; } global $wpdb; if ( empty( $user_id ) ) { $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->dokan_withdraw} ORDER BY date DESC LIMIT %d, %d", $offset, $limit ) ); } else { $result = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->dokan_withdraw} WHERE user_id =%d ORDER BY date DESC LIMIT %d, %d", $user_id, $offset, $limit ) ); } return $result; } /** * Print the approved user withdraw requests * * @param int $user_id * * @return void */ public function user_approved_withdraws( $user_id ) { if ( ! current_user_can( 'dokan_manage_withdraw' ) ) { return; } $requests = dokan()->withdraw->get_withdraw_requests( $user_id, 1, 100 ); if ( $requests ) { dokan_get_template_part( 'withdraw/approved-request-listing', '', array( 'requests' => $requests, ) ); } else { $this->show_warning_message( __( 'Sorry, no transactions were found!', 'dokan-lite' ) ); } } /** * Print the cancelled user withdraw requests * * @param int $user_id * * @return void */ public function user_cancelled_withdraws( $user_id ) { if ( ! current_user_can( 'dokan_manage_withdraw' ) ) { return; } $requests = dokan()->withdraw->get_withdraw_requests( $user_id, 2, 100 ); if ( $requests ) { dokan_get_template_part( 'withdraw/cancelled-request-listing', '', array( 'requests' => $requests, ) ); } else { $message = __( 'Sorry, no transactions were found!', 'dokan-lite' ); $this->show_warning_message( $message ); } } }