/**
  * Delete wishlist on bulk action
  *
  * @since 1.0.0
  */
 public function process_bulk_action()
 {
     // Detect when a bulk action is being triggered...
     if (!isset($_REQUEST['page']) || $_REQUEST['page'] != YITH_Commissions()->get_screen() || !isset($_REQUEST['action']) || !isset($_REQUEST['commissions'])) {
         return;
     }
     $vendor = yith_get_vendor('current', 'user');
     if (!$vendor->is_super_user()) {
         return;
     }
     $action = $_REQUEST['action'] != -1 ? $_REQUEST['action'] : $_REQUEST['action2'];
     $commissions = $_REQUEST['commissions'];
     $message = 'updated';
     // change status action
     if (in_array($action, array_keys(YITH_Commissions()->get_status()))) {
         foreach ($commissions as $commission_id) {
             YITH_Commission($commission_id)->update_status($action);
         }
     } else {
         if ('pay' == $action) {
             $data = array();
             foreach ($commissions as $commission_id) {
                 $commission = YITH_Commission($commission_id);
                 $vendor = $commission->get_vendor();
                 $data[] = array('paypal_email' => $vendor->paypal_email, 'amount' => round($commission->get_amount(), 2), 'request_id' => $commission->id);
             }
             // process payment
             $result = YITH_Vendors_Credit()->pay($data);
             foreach ($commissions as $commission_id) {
                 /** @var YITH_Commission $commission */
                 $commission = YITH_Commission($commission_id);
                 // set as processing, because paypal will set as paid as soon as the transaction is completed
                 if ($result['status']) {
                     $message = 'pay-process';
                     $commission->update_status('processing');
                 } else {
                     $message = 'pay-failed';
                     $commission->add_note(sprintf(__('Payment failed: %s', 'yith_wc_product_vendors'), $result['messages']));
                 }
             }
         } else {
             return;
         }
     }
     wp_redirect(esc_url_raw(add_query_arg('message', $message, wp_get_referer())));
     exit;
 }
        }
        /**
         * Remove the option where give the ability to vendor to choose the payment method
         *
         * @param array $fields
         *
         * @return array
         */
        public function remove_vendor_payment_choosing($fields)
        {
            if ('choose' != $this->payment_method) {
                unset($fields['payment_method']);
            }
            return $fields;
        }
    }
}
/**
 * Main instance of plugin
 *
 * @return YITH_Vendors_Credit
 * @since  1.0
 */
if (!function_exists('YITH_Vendors_Credit')) {
    function YITH_Vendors_Credit()
    {
        return YITH_Vendors_Credit::instance();
    }
}
YITH_Vendors_Credit();