Exemplo n.º 1
0
/**
 * Resend the Email Purchase Receipt. (This can be done from the Payment History page)
 *
 * @since 1.0
 * @param array $data Payment Data
 * @return void
 */
function edd_resend_purchase_receipt($data)
{
    $purchase_id = absint($data['purchase_id']);
    if (empty($purchase_id)) {
        return;
    }
    if (!current_user_can('edit_shop_payments')) {
        wp_die(__('You do not have permission to edit this payment record', 'easy-digital-downloads'), __('Error', 'easy-digital-downloads'), array('response' => 403));
    }
    $email = !empty($_GET['email']) ? sanitize_text_field($_GET['email']) : '';
    if (empty($email)) {
        $customer = new EDD_Customer(edd_get_payment_customer_id($purchase_id));
        $email = $customer->email;
    }
    edd_email_purchase_receipt($purchase_id, false, $email);
    // Grab all downloads of the purchase and update their file download limits, if needed
    // This allows admins to resend purchase receipts to grant additional file downloads
    $downloads = edd_get_payment_meta_cart_details($purchase_id, true);
    if (is_array($downloads)) {
        foreach ($downloads as $download) {
            $limit = edd_get_file_download_limit($download['id']);
            if (!empty($limit)) {
                edd_set_file_download_limit_override($download['id'], $purchase_id);
            }
        }
    }
    wp_redirect(add_query_arg(array('edd-message' => 'email_sent', 'edd-action' => false, 'purchase_id' => false)));
    exit;
}
/**
 * Resend Email Purchase Receipt
 *
 * @access      private
 * @since       1.0 
 * @return      void
*/
function edd_resend_purchase_receipt($data)
{
    $purchase_id = $data['purchase_id'];
    edd_email_purchase_receipt($purchase_id, false);
    wp_redirect(add_query_arg(array('edd-message' => 'email_sent', 'edd-action' => false, 'purchase_id' => false)));
    exit;
}
/**
 * Resend the Email Purchase Receipt. (This can be done from the Payment History page)
 *
 * @since 1.0
 * @param array $data Payment Data
 * @return void
 */
function edd_resend_purchase_receipt($data)
{
    $purchase_id = $data['purchase_id'];
    edd_email_purchase_receipt($purchase_id, false);
    // Grab all downloads of the purchase and update their file download limits, if needed
    // This allows admins to resend purchase receipts to grant additional file downloads
    $downloads = edd_get_payment_meta_downloads($purchase_id);
    if (is_array($downloads)) {
        foreach ($downloads as $download) {
            $limit = edd_get_file_download_limit($download['id']);
            if (!empty($limit)) {
                edd_set_file_download_limit_override($download['id'], $purchase_id);
            }
        }
    }
    wp_redirect(add_query_arg(array('edd-message' => 'email_sent', 'edd-action' => false, 'purchase_id' => false)));
    exit;
}
/**
 * Resends a purchase receipt
 */
function resend_purchase_receipt()
{
    authorize_request();
    $payment_id = absint($_GET['payment_id']);
    edd_email_purchase_receipt($payment_id, false);
    // Grab all downloads of the purchase and update their file download limits, if needed
    // This allows admins to resend purchase receipts to grant additional file downloads
    $downloads = edd_get_payment_meta_downloads($payment_id);
    if (is_array($downloads)) {
        foreach ($downloads as $download) {
            $limit = edd_get_file_download_limit($download['id']);
            if (!empty($limit)) {
                edd_set_file_download_limit_override($download['id'], $payment_id);
            }
        }
    }
    die('<script>window.close();</script>');
}
 /**
  * Process the bulk actions
  *
  * @access public
  * @since 1.4
  * @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()) {
             edd_delete_purchase($id);
         }
         if ('set-status-publish' === $this->current_action()) {
             edd_update_payment_status($id, 'publish');
         }
         if ('set-status-pending' === $this->current_action()) {
             edd_update_payment_status($id, 'pending');
         }
         if ('set-status-refunded' === $this->current_action()) {
             edd_update_payment_status($id, 'refunded');
         }
         if ('set-status-revoked' === $this->current_action()) {
             edd_update_payment_status($id, 'revoked');
         }
         if ('set-status-failed' === $this->current_action()) {
             edd_update_payment_status($id, 'failed');
         }
         if ('set-status-abandoned' === $this->current_action()) {
             edd_update_payment_status($id, 'abandoned');
         }
         if ('set-status-preapproval' === $this->current_action()) {
             edd_update_payment_status($id, 'preapproval');
         }
         if ('set-status-cancelled' === $this->current_action()) {
             edd_update_payment_status($id, 'cancelled');
         }
         if ('resend-receipt' === $this->current_action()) {
             edd_email_purchase_receipt($id, false);
         }
         do_action('edd_payments_table_do_bulk_action', $id, $this->current_action());
     }
 }
/**
 * Update Edited Purchase
 *
 * Updates the purchase data for a payment.
 * Used primarily for adding new downloads to a purchase.
 *
 * @since 1.0
 * @param $data Arguments passed
 * @return void
 */
function edd_update_edited_purchase($data)
{
    if (wp_verify_nonce($data['edd-payment-nonce'], 'edd_payment_nonce')) {
        $payment_id = $_POST['payment-id'];
        $payment_data = edd_get_payment_meta($payment_id);
        if (isset($_POST['edd-purchased-downloads'])) {
            $download_list = array();
            foreach ($_POST['edd-purchased-downloads'] as $key => $download) {
                if (isset($download['options']['price_id'])) {
                    $download_list[] = array('id' => $key, 'options' => array('price_id' => $download['options']['price_id']));
                } else {
                    $download_list[] = array('id' => $download);
                }
            }
            $payment_data['downloads'] = serialize($download_list);
        }
        $user_info = maybe_unserialize($payment_data['user_info']);
        $user_info['email'] = strip_tags($_POST['edd-buyer-email']);
        $user_info['user_id'] = strip_tags(intval($_POST['edd-buyer-user-id']));
        $payment_data['user_info'] = serialize($user_info);
        update_post_meta($payment_id, '_edd_payment_meta', $payment_data);
        update_post_meta($payment_id, '_edd_payment_user_email', strip_tags($_POST['edd-buyer-email']));
        update_post_meta($payment_id, '_edd_payment_user_id', strip_tags(intval($_POST['edd-buyer-user-id'])));
        if (!empty($_POST['edd-payment-note'])) {
            $note = wp_kses($_POST['edd-payment-note'], array());
            $note_id = edd_insert_payment_note($payment_id, $note);
        }
        if (!empty($_POST['edd-payment-amount'])) {
            update_post_meta($payment_id, '_edd_payment_total', sanitize_text_field(edd_sanitize_amount($_POST['edd-payment-amount'])));
        }
        if (!empty($_POST['edd-unlimited-downloads'])) {
            add_post_meta($payment_id, '_unlimited_file_downloads', '1');
        } else {
            delete_post_meta($payment_id, '_unlimited_file_downloads');
        }
        if ($_POST['edd-old-status'] != $_POST['edd-payment-status']) {
            edd_update_payment_status($payment_id, $_POST['edd-payment-status']);
        }
        if ($_POST['edd-payment-status'] == 'publish' && isset($_POST['edd-payment-send-email'])) {
            // Send the purchase receipt
            edd_email_purchase_receipt($payment_id, false);
        }
        do_action('edd_update_edited_purchase', $payment_id);
    }
}
Exemplo n.º 7
0
/**
 * Update Edited Purchase
 *
 * Updates the purchase data for a payment.
 * Used primarily for adding new downloads to a purchase.
 *
 * @access      private
 * @since       1.0
 * @return      void
*/
function edd_update_edited_purchase($data)
{
    if (wp_verify_nonce($data['edd-payment-nonce'], 'edd_payment_nonce')) {
        $payment_id = $_POST['payment-id'];
        $payment_data = edd_get_payment_meta($payment_id);
        if (isset($_POST['edd-purchased-downloads'])) {
            $updated_downloads = array();
            foreach ($_POST['edd-purchased-downloads'] as $download) {
                if (isset($payment_data['cart_details'])) {
                    $updated_downloads[] = array('id' => $download);
                } else {
                    $updated_downloads[] = $download;
                }
            }
            $payment_data['downloads'] = serialize($updated_downloads);
        }
        $payment_data['email'] = strip_tags($_POST['edd-buyer-email']);
        update_post_meta($payment_id, '_edd_payment_meta', $payment_data);
        update_post_meta($payment_id, '_edd_payment_user_email', $payment_data['email']);
        if (isset($_POST['edd-payment-note'])) {
            $note = wp_kses($_POST['edd-payment-note'], array());
            $note_id = edd_insert_payment_note($payment_id, $note);
        }
        if ($_POST['edd-old-status'] != $_POST['edd-payment-status']) {
            edd_update_payment_status($payment_id, $_POST['edd-payment-status']);
        }
        if ($_POST['edd-payment-status'] == 'publish' && isset($_POST['edd-payment-send-email'])) {
            // send the purchase receipt
            edd_email_purchase_receipt($payment_id, false);
        }
    }
}
/**
 * Update Edited Purchase
 *
 * Updates the purchase data for a payment. 
 * Used primarily for adding new downloads to a purchase.
 *
 * @access      private
 * @since       1.0 
 * @return      void
*/
function edd_update_edited_purchase($data)
{
    if (wp_verify_nonce($data['edd-payment-nonce'], 'edd_payment_nonce')) {
        $payment_id = $_POST['payment-id'];
        $payment_data = edd_get_payment_meta($payment_id);
        if (isset($_POST['edd-purchased-downloads'])) {
            $updated_downloads = array();
            foreach ($_POST['edd-purchased-downloads'] as $download) {
                if (isset($payment_data['cart_details'])) {
                    $updated_downloads[] = array('id' => $download);
                } else {
                    $updated_downloads[] = $download;
                }
            }
            $payment_data['downloads'] = serialize($updated_downloads);
        }
        $payment_data['email'] = strip_tags($_POST['edd-buyer-email']);
        update_post_meta($payment_id, '_edd_payment_meta', $payment_data);
        update_post_meta($payment_id, '_edd_payment_user_email', $payment_data['email']);
        if ($_POST['edd-old-status'] != $_POST['edd-payment-status']) {
            if ($_POST['edd-payment-status'] == 'refunded') {
                // update sale counts and earnings for all purchased products
                foreach ($_POST['edd-purchased-downloads'] as $download) {
                    edd_undo_purchase($download, $payment_id);
                }
            }
            wp_update_post(array('ID' => $payment_id, 'post_status' => $_POST['edd-payment-status']));
        }
        if ($_POST['edd-payment-status'] == 'publish' && isset($_POST['edd-payment-send-email'])) {
            // send the purchase receipt
            edd_email_purchase_receipt($payment_id, false);
        }
    }
}