Exemplo n.º 1
0
 /**
  * Delete a payment.
  *
  * @since 1.0
  *
  * @param int $payment_id ID of the payment to delete.
  */
 public static function delete_payment($payment_id)
 {
     // Delete the payment
     give_delete_purchase($payment_id);
 }
Exemplo n.º 2
0
 /**
  * Process the bulk actions
  *
  * @access public
  * @since  1.0
  * @return void
  */
 public function process_bulk_action()
 {
     $ids = isset($_GET['payment']) ? $_GET['payment'] : false;
     $action = $this->current_action();
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     if (empty($action)) {
         return;
     }
     foreach ($ids as $id) {
         // Detect when a bulk action is being triggered...
         if ('delete' === $this->current_action()) {
             give_delete_purchase($id);
         }
         if ('set-status-publish' === $this->current_action()) {
             give_update_payment_status($id, 'publish');
         }
         if ('set-status-pending' === $this->current_action()) {
             give_update_payment_status($id, 'pending');
         }
         if ('set-status-refunded' === $this->current_action()) {
             give_update_payment_status($id, 'refunded');
         }
         if ('set-status-revoked' === $this->current_action()) {
             give_update_payment_status($id, 'revoked');
         }
         if ('set-status-failed' === $this->current_action()) {
             give_update_payment_status($id, 'failed');
         }
         if ('set-status-abandoned' === $this->current_action()) {
             give_update_payment_status($id, 'abandoned');
         }
         if ('resend-receipt' === $this->current_action()) {
             give_email_donation_receipt($id, false);
         }
         do_action('give_payments_table_do_bulk_action', $id, $this->current_action());
     }
 }
Exemplo n.º 3
0
/**
 * Delete a customer
 *
 * @since  1.0
 *
 * @param  array $args The $_POST array being passeed
 *
 * @return int         Wether it was a successful deletion
 */
function give_customer_delete($args)
{
    $customer_edit_role = apply_filters('give_edit_customers_role', 'edit_give_payments');
    if (!is_admin() || !current_user_can($customer_edit_role)) {
        wp_die(__('You do not have permission to delete this donor.', 'give'));
    }
    if (empty($args)) {
        return;
    }
    $customer_id = (int) $args['customer_id'];
    $confirm = !empty($args['give-customer-delete-confirm']) ? true : false;
    $remove_data = !empty($args['give-customer-delete-records']) ? true : false;
    $nonce = $args['_wpnonce'];
    if (!wp_verify_nonce($nonce, 'delete-customer')) {
        wp_die(__('Cheatin\' eh?!', 'give'));
    }
    if (!$confirm) {
        give_set_error('customer-delete-no-confirm', __('Please confirm you want to delete this donor', 'give'));
    }
    if (give_get_errors()) {
        wp_redirect(admin_url('edit.php?post_type=give_forms&page=give-donors&view=overview&id=' . $customer_id));
        exit;
    }
    $customer = new Give_Customer($customer_id);
    do_action('give_pre_delete_customer', $customer_id, $confirm, $remove_data);
    $success = false;
    if ($customer->id > 0) {
        $payments_array = explode(',', $customer->payment_ids);
        $success = Give()->customers->delete($customer->id);
        if ($success) {
            if ($remove_data) {
                // Remove all payments, logs, etc
                foreach ($payments_array as $payment_id) {
                    give_delete_purchase($payment_id, false, true);
                }
            } else {
                // Just set the payments to customer_id of 0
                foreach ($payments_array as $payment_id) {
                    give_update_payment_meta($payment_id, '_give_payment_customer_id', 0);
                }
            }
            $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&give-message=customer-deleted');
        } else {
            give_set_error('give-donor-delete-failed', __('Error deleting donor', 'give'));
            $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors&view=delete&id=' . $customer_id);
        }
    } else {
        give_set_error('give-customer-delete-invalid-id', __('Invalid Donor ID', 'give'));
        $redirect = admin_url('edit.php?post_type=give_forms&page=give-donors');
    }
    wp_redirect($redirect);
    exit;
}
Exemplo n.º 4
0
 /**
  * Process the bulk actions
  *
  * @access public
  * @since  1.0
  * @return void
  */
 public function process_bulk_action()
 {
     $ids = isset($_GET['payment']) ? $_GET['payment'] : false;
     $action = $this->current_action();
     if (!is_array($ids)) {
         $ids = array($ids);
     }
     if (empty($action)) {
         return;
     }
     foreach ($ids as $id) {
         // Detect when a bulk action is being triggered...
         switch ($this->current_action()) {
             case 'delete':
                 give_delete_purchase($id);
                 break;
             case 'set-status-publish':
                 give_update_payment_status($id, 'publish');
                 break;
             case 'set-status-pending':
                 give_update_payment_status($id, 'pending');
                 break;
             case 'set-status-refunded':
                 give_update_payment_status($id, 'refunded');
                 break;
             case 'set-status-revoked':
                 give_update_payment_status($id, 'revoked');
                 break;
             case 'set-status-failed':
                 give_update_payment_status($id, 'failed');
                 break;
             case 'set-status-cancelled':
                 give_update_payment_status($id, 'cancelled');
                 break;
             case 'set-status-abandoned':
                 give_update_payment_status($id, 'abandoned');
                 break;
             case 'set-status-preapproval':
                 give_update_payment_status($id, 'preapproval');
                 break;
             case 'resend-receipt':
                 give_email_donation_receipt($id, false);
                 break;
         }
         /**
          * Fires after triggering bulk action on payments table.
          *
          * @since 1.0
          *
          * @param int    $id The ID of the payment.
          * @param string $current_action The action that is being triggered.
          */
         do_action('give_payments_table_do_bulk_action', $id, $this->current_action());
     }
 }
Exemplo n.º 5
0
/**
 * Trigger a Purchase Deletion
 *
 * @since 1.0
 *
 * @param $data Arguments passed
 *
 * @return void
 */
function give_trigger_purchase_delete($data)
{
    if (wp_verify_nonce($data['_wpnonce'], 'give_payment_nonce')) {
        $payment_id = absint($data['purchase_id']);
        if (!current_user_can('edit_give_payments', $payment_id)) {
            wp_die(__('You do not have permission to edit this payment record', 'give'), __('Error', 'give'), array('response' => 403));
        }
        give_delete_purchase($payment_id);
        wp_redirect(admin_url('/edit.php?post_type=give_forms&page=give-payment-history&give-message=payment_deleted'));
        give_die();
    }
}