Пример #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 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>');
}
Пример #4
0
/**
 * Retrieves a new download link for a purchased file
 *
 * @since 2.0
 * @return string
*/
function edd_ajax_generate_file_download_link()
{
    if (!current_user_can('view_shop_reports')) {
        die('-1');
    }
    $payment_id = absint($_POST['payment_id']);
    $download_id = absint($_POST['download_id']);
    $price_id = absint($_POST['price_id']);
    if (empty($payment_id)) {
        die('-2');
    }
    if (empty($download_id)) {
        die('-3');
    }
    $payment_key = edd_get_payment_key($payment_id);
    $email = edd_get_payment_user_email($payment_id);
    $limit = edd_get_file_download_limit($download_id);
    if (!empty($limit)) {
        // Increase the file download limit when generating new links
        edd_set_file_download_limit_override($download_id, $payment_id);
    }
    $files = edd_get_download_files($download_id, $price_id);
    if (!$files) {
        die('-4');
    }
    $file_urls = '';
    foreach ($files as $file_key => $file) {
        $file_urls .= edd_get_download_file_url($payment_key, $email, $file_key, $download_id, $price_id);
        $file_urls .= "\n\n";
    }
    die($file_urls);
}
Пример #5
0
/**
 * Fetches emails from queue and sends them in batches of 10
 * 
 * @access public
 * @since 0.9.2
 * @return $sent (number of emails successfully processed)
 */
function edd_pup_ajax_trigger()
{
    global $wpdb;
    global $edd_options;
    global $wpdb;
    if (!empty($_POST['email_id']) && absint($_POST['email_id']) != 0) {
        $email_id = $_POST['email_id'];
    } else {
        $email_id = get_transient('edd_pup_sending_email_' . get_current_user_id());
    }
    // Refresh email ID transient
    set_transient('edd_pup_sending_email_' . get_current_user_id(), $email_id, 60);
    $batch = $_POST['iteration'];
    $sent = $_POST['sent'];
    $limit = 10;
    $rows = array();
    /* Throttle emails if enabled in settings
    	if ( isset( $edd_options['edd_pup_throttle'] ) ) {
    		
    		$last = $wpdb->query( "SELECT UNIX_TIMESTAMP(sent_date) FROM $wpdb->edd_pup_queue WHERE email_id = $email_id AND sent = 1 ORDER BY sent_date DESC LIMIT 1" )
    		$now = time();
    		
    		if ( ( $now - $last ) < $edd_options['edd_pup_throttle_int'] ) {
    			echo json_encode(array('status'=>'new','sent'=>0,'total'=>absint($total),'processed'=>absint($processed+$count)));
    			exit;
    		}
    	}*/
    $query = "SELECT * FROM {$wpdb->edd_pup_queue} WHERE email_id = {$email_id} AND sent = 0 LIMIT {$limit}";
    $customers = $wpdb->get_results($query, ARRAY_A);
    foreach ($customers as $customer) {
        $trigger = edd_pup_ajax_send_email($customer['customer_id'], $email_id, $edd_options['edd_pup_test']);
        // Reset file download limits for customers' eligible updates
        $customer_updates = edd_pup_get_customer_updates($customer['customer_id'], $email_id);
        foreach ($customer_updates as $download) {
            $limit = edd_get_file_download_limit($download['id']);
            if (!empty($limit)) {
                edd_set_file_download_limit_override($download['id'], $customer['customer_id']);
            }
        }
        if (true == $trigger) {
            $rows[] = $customer['eddpup_id'];
            $sent++;
        }
    }
    // Designate emails in database as having been sent
    if (!empty($rows)) {
        $updateids = implode(',', $rows);
        $wpdb->query("UPDATE {$wpdb->edd_pup_queue} SET sent=1 WHERE eddpup_id IN ({$updateids})");
    }
    echo $sent;
    exit;
}