/** * Get the data being exported * * @return array $data */ public function get_data() { global $wpdb; $data = array(); $campaign = $this->campaign; $campaign = atcf_get_campaign($campaign); $backers = $campaign->backers(); if (empty($backers)) { return $data; } foreach ($backers as $log) { $payment_id = get_post_meta($log->ID, '_edd_log_payment_id', true); $payment = get_post($payment_id); $payment_meta = edd_get_payment_meta($payment_id); $user_info = edd_get_payment_meta_user_info($payment_id); $downloads = edd_get_payment_meta_cart_details($payment_id); $total = edd_get_payment_amount($payment_id); $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email']; $products = ''; if ($downloads) { foreach ($downloads as $key => $download) { // Download ID $id = isset($payment_meta['cart_details']) ? $download['id'] : $download; // If the download has variable prices, override the default price $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null; $price = edd_get_download_final_price($id, $user_info, $price_override); // Display the Downoad Name $products .= get_the_title($id) . ' - '; if (isset($downloads[$key]['item_number'])) { $price_options = $downloads[$key]['item_number']['options']; if (isset($price_options['price_id'])) { $products .= edd_get_price_option_name($id, $price_options['price_id']) . ' - '; } } $products .= html_entity_decode(edd_currency_filter($price)); if ($key != count($downloads) - 1) { $products .= ' / '; } } } if (is_numeric($user_id)) { $user = get_userdata($user_id); } else { $user = false; } $shipping = isset($payment_meta['shipping']) ? $payment_meta['shipping'] : null; $data[] = apply_filters('atcf_csv_cols_values', array('id' => $payment_id, 'email' => $payment_meta['email'], 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'shipping' => isset($shipping) ? implode("\n", $shipping) : '', 'products' => $products, 'amount' => html_entity_decode(edd_currency_filter(edd_format_amount($total))), 'tax' => html_entity_decode(edd_payment_tax($payment_id, $payment_meta)), 'discount' => isset($user_info['discount']) && $user_info['discount'] != 'none' ? $user_info['discount'] : __('none', 'atcf'), 'gateway' => edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true)), 'key' => $payment_meta['key'], 'date' => date_i18n(get_option('date_format'), strtotime($payment->post_date)), 'user' => $user ? $user->display_name : __('guest', 'atcf'), 'status' => edd_get_payment_status($payment, true)), $payment_id); } $data = apply_filters('edd_export_get_data', $data); $data = apply_filters('edd_export_get_data_' . $this->export_type, $data); return $data; }
/** * Email Download Purchase Receipt * * Email the download link(s) and payment confirmation to the buyer. * * @access private * @since 1.0 * @return void */ function edd_email_purchase_receipt($payment_id, $admin_notice = true) { global $edd_options; $payment_data = edd_get_payment_meta($payment_id); $user_info = maybe_unserialize($payment_data['user_info']); if (isset($user_info['id']) && $user_info['id'] > 0) { $user_data = get_userdata($user_info['id']); $name = $user_data->display_name; } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { $name = $user_info['first_name'] . ' ' . $user_info['last_name']; } else { $name = $user_info['email']; } $message = edd_get_email_body_header(); $message .= edd_get_email_body_content($payment_id, $payment_data); $message .= edd_get_email_body_footer(); $from_name = isset($edd_options['from_name']) ? $edd_options['from_name'] : get_bloginfo('name'); $from_email = isset($edd_options['from_email']) ? $edd_options['from_email'] : get_option('admin_email'); $subject = isset($edd_options['purchase_subject']) && strlen(trim($edd_options['purchase_subject'])) > 0 ? edd_email_template_tags($edd_options['purchase_subject'], $payment_data, $payment_id) : __('Purchase Receipt', 'edd'); $headers = "From: " . stripslashes_deep(html_entity_decode($from_name, ENT_COMPAT, 'UTF-8')) . " <{$from_email}>\r\n"; $headers .= "Reply-To: " . $from_email . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=utf-8\r\n"; // allow add-ons to add file attachments $attachments = apply_filters('edd_receipt_attachments', array(), $payment_id, $payment_data); wp_mail($payment_data['email'], $subject, $message, $headers, $attachments); if ($admin_notice) { /* send an email notification to the admin */ $admin_email = edd_get_admin_notice_emails(); $admin_subject = apply_filters('edd_admin_purchase_notification_subject', __('New download purchase', 'edd'), $payment_id, $payment_data); $admin_message = __('Hello', 'edd') . "\n\n" . sprintf(__('A %s purchase has been made', 'edd'), edd_get_label_plural()) . ".\n\n"; $admin_message .= sprintf(__('%s sold:', 'edd'), edd_get_label_plural()) . "\n\n"; $download_list = ''; $downloads = maybe_unserialize($payment_data['downloads']); if (is_array($downloads)) { foreach ($downloads as $download) { $id = isset($payment_data['cart_details']) ? $download['id'] : $download; $download_list .= html_entity_decode(get_the_title($id), ENT_COMPAT, 'UTF-8') . "\n"; } } $gateway = edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true)); $admin_message .= $download_list . "\n"; $admin_message .= __('Purchased by: ', 'edd') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n"; $admin_message .= __('Amount: ', 'edd') . " " . html_entity_decode(edd_currency_filter(edd_format_amount($payment_data['amount'])), ENT_COMPAT, 'UTF-8') . "\n\n"; $admin_message .= __('Payment Method: ', 'edd') . " " . $gateway . "\n\n"; $admin_message .= __('Thank you', 'edd'); $admin_message = apply_filters('edd_admin_purchase_notification', $admin_message, $payment_id, $payment_data); $admin_headers = apply_filters('edd_admin_purchase_notification_headers', array(), $payment_id, $payment_data); $admin_attachments = apply_filters('edd_admin_purchase_notification_attachments', array(), $payment_id, $payment_data); wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers, $admin_attachments); } }
<?php do_action('edd_view_order_details_payment_meta_before', $payment_id); ?> <?php $gateway = edd_get_payment_gateway($payment_id); if ($gateway) { ?> <div class="edd-order-gateway edd-admin-box-inside"> <p> <span class="label"><?php _e('Gateway:', 'edd'); ?> </span> <?php echo edd_get_gateway_admin_label($gateway); ?> </p> </div> <?php } ?> <div class="edd-order-payment-key edd-admin-box-inside"> <p> <span class="label"><?php _e('Key:', 'edd'); ?> </span> <span><?php echo edd_get_payment_key($payment_id);
/** * Sale Notification Template Body * * @since 1.7 * @author Daniel J Griffiths * @param int $payment_id Payment ID * @param array $payment_data Payment Data * @return string $email_body Body of the email */ function edd_get_sale_notification_body_content($payment_id = 0, $payment_data = array()) { global $edd_options; $user_info = maybe_unserialize($payment_data['user_info']); $email = edd_get_payment_user_email($payment_id); if (isset($user_info['id']) && $user_info['id'] > 0) { $user_data = get_userdata($user_info['id']); $name = $user_data->display_name; } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { $name = $user_info['first_name'] . ' ' . $user_info['last_name']; } else { $name = $email; } $download_list = ''; $downloads = maybe_unserialize($payment_data['downloads']); if (is_array($downloads)) { foreach ($downloads as $download) { $id = isset($payment_data['cart_details']) ? $download['id'] : $download; $title = get_the_title($id); if (isset($download['options'])) { if (isset($download['options']['price_id'])) { $title .= ' - ' . edd_get_price_option_name($id, $download['options']['price_id'], $payment_id); } } $download_list .= html_entity_decode($title, ENT_COMPAT, 'UTF-8') . "\n"; } } $gateway = edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true)); $default_email_body = __('Hello', 'edd') . "\n\n" . sprintf(__('A %s purchase has been made', 'edd'), edd_get_label_plural()) . ".\n\n"; $default_email_body .= sprintf(__('%s sold:', 'edd'), edd_get_label_plural()) . "\n\n"; $default_email_body .= $download_list . "\n\n"; $default_email_body .= __('Purchased by: ', 'edd') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n"; $default_email_body .= __('Amount: ', 'edd') . " " . html_entity_decode(edd_currency_filter(edd_format_amount(edd_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8') . "\n"; $default_email_body .= __('Payment Method: ', 'edd') . " " . $gateway . "\n\n"; $default_email_body .= __('Thank you', 'edd'); $email = isset($edd_options['sale_notification']) ? stripslashes($edd_options['sale_notification']) : $default_email_body; //$email_body = edd_email_template_tags( $email, $payment_data, $payment_id, true ); $email_body = edd_do_email_tags($email, $payment_id); return apply_filters('edd_sale_notification', wpautop($email_body), $payment_id, $payment_data); }
/** * Get the Export Data * * @access public * @since 2.4 * @global object $wpdb Used to query the database using the WordPress * Database API * @return array $data The data for the CSV file */ public function get_data() { global $wpdb; $data = array(); $args = array('number' => 30, 'page' => $this->step, 'status' => $this->status); if (!empty($this->start) || !empty($this->end)) { $args['date_query'] = array(array('after' => date('Y-n-d H:i:s', strtotime($this->start)), 'before' => date('Y-n-d H:i:s', strtotime($this->end)), 'inclusive' => true)); } //echo json_encode($args ); exit; $payments = edd_get_payments($args); if ($payments) { foreach ($payments as $payment) { $payment_meta = edd_get_payment_meta($payment->ID); $user_info = edd_get_payment_meta_user_info($payment->ID); $downloads = edd_get_payment_meta_cart_details($payment->ID); $total = edd_get_payment_amount($payment->ID); $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email']; $products = ''; $skus = ''; if ($downloads) { foreach ($downloads as $key => $download) { // Download ID $id = isset($payment_meta['cart_details']) ? $download['id'] : $download; // If the download has variable prices, override the default price $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null; $price = edd_get_download_final_price($id, $user_info, $price_override); // Display the Downoad Name $products .= get_the_title($id) . ' - '; if (edd_use_skus()) { $sku = edd_get_download_sku($id); if (!empty($sku)) { $skus .= $sku; } } if (isset($downloads[$key]['item_number']) && isset($downloads[$key]['item_number']['options'])) { $price_options = $downloads[$key]['item_number']['options']; if (isset($price_options['price_id'])) { $products .= edd_get_price_option_name($id, $price_options['price_id'], $payment->ID) . ' - '; } } $products .= html_entity_decode(edd_currency_filter($price)); if ($key != count($downloads) - 1) { $products .= ' / '; if (edd_use_skus()) { $skus .= ' / '; } } } } if (is_numeric($user_id)) { $user = get_userdata($user_id); } else { $user = false; } $data[] = array('id' => $payment->ID, 'seq_id' => edd_get_payment_number($payment->ID), 'email' => $payment_meta['email'], 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'address1' => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '', 'address2' => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '', 'city' => isset($user_info['address']['city']) ? $user_info['address']['city'] : '', 'state' => isset($user_info['address']['state']) ? $user_info['address']['state'] : '', 'country' => isset($user_info['address']['country']) ? $user_info['address']['country'] : '', 'zip' => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '', 'products' => $products, 'skus' => $skus, 'amount' => html_entity_decode(edd_format_amount($total)), 'tax' => html_entity_decode(edd_format_amount(edd_get_payment_tax($payment->ID, $payment_meta))), 'discount' => isset($user_info['discount']) && $user_info['discount'] != 'none' ? $user_info['discount'] : __('none', 'edd'), 'gateway' => edd_get_gateway_admin_label(get_post_meta($payment->ID, '_edd_payment_gateway', true)), 'trans_id' => edd_get_payment_transaction_id($payment->ID), 'key' => $payment_meta['key'], 'date' => $payment->post_date, 'user' => $user ? $user->display_name : __('guest', 'edd'), 'status' => edd_get_payment_status($payment, true)); } $data = apply_filters('edd_export_get_data', $data); $data = apply_filters('edd_export_get_data_' . $this->export_type, $data); return $data; } return false; }
/** * Get the Export Data * * @access public * @since 1.4.4 * @global object $wpdb Used to query the database using the WordPress * Database API * @return array $data The data for the CSV file */ public function get_data() { global $wpdb, $edd_options; $data = array(); $payments = edd_get_payments(array('offset' => 0, 'number' => -1, 'mode' => edd_is_test_mode() ? 'test' : 'live', 'status' => isset($_POST['edd_export_payment_status']) ? $_POST['edd_export_payment_status'] : 'any', 'month' => isset($_POST['month']) ? absint($_POST['month']) : date('n'), 'year' => isset($_POST['year']) ? absint($_POST['year']) : date('Y'))); foreach ($payments as $payment) { // skip over payments that don't have upsells in them if (!get_post_meta($payment->ID, '_edd_payment_upsell_total', true)) { continue; } $payment_meta = edd_get_payment_meta($payment->ID); $user_info = edd_get_payment_meta_user_info($payment->ID); $downloads = edd_get_payment_meta_cart_details($payment->ID); $total = edd_csau_get_payment_amount($payment->ID, 'upsell'); $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email']; $products = ''; $skus = ''; if ($downloads) { foreach ($downloads as $key => $download) { // skip over downloads which aren't upsells if (!isset($download['item_number']['upsell'])) { continue; } // Download ID $id = isset($payment_meta['cart_details']) ? $download['id'] : $download; // If the download has variable prices, override the default price $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null; $price = edd_get_download_final_price($id, $user_info, $price_override); // Display the Downoad Name $products .= get_the_title($id) . ' - '; if (edd_use_skus()) { $sku = edd_get_download_sku($id); if (!empty($sku)) { $skus .= $sku; } } if (isset($downloads[$key]['item_number']) && isset($downloads[$key]['item_number']['options'])) { $price_options = $downloads[$key]['item_number']['options']; if (isset($price_options['price_id'])) { $products .= edd_get_price_option_name($id, $price_options['price_id']) . ' - '; } } $products .= html_entity_decode(edd_currency_filter($price)); if ($key != count($downloads) - 1) { $products .= ' / '; if (edd_use_skus()) { $skus .= ' / '; } } } } if (is_numeric($user_id)) { $user = get_userdata($user_id); } else { $user = false; } $data[] = array('id' => $payment->ID, 'email' => $payment_meta['email'], 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'products' => $products, 'skus' => $skus, 'amount' => html_entity_decode(edd_format_amount($total)), 'tax' => html_entity_decode(edd_get_payment_tax($payment->ID, $payment_meta)), 'discount' => isset($user_info['discount']) && $user_info['discount'] != 'none' ? $user_info['discount'] : __('none', 'edd'), 'gateway' => edd_get_gateway_admin_label(get_post_meta($payment->ID, '_edd_payment_gateway', true)), 'key' => $payment_meta['key'], 'date' => $payment->post_date, 'user' => $user ? $user->display_name : __('guest', 'edd'), 'status' => edd_get_payment_status($payment, true)); if (!edd_use_skus()) { unset($data['skus']); } } $data = apply_filters('edd_export_get_data', $data); $data = apply_filters('edd_export_get_data_' . $this->export_type, $data); return $data; }
/** * Sales Summary Dashboard Widget * * @access private * @author Sunny Ratilal * @since 1.2.2 */ function edd_dashboard_sales_widget() { $top_selling_args = array('post_type' => 'download', 'posts_per_page' => 1, 'post_status' => 'publish', 'meta_key' => '_edd_download_sales', 'meta_compare' => '>', 'meta_value' => 0, 'orderby' => 'meta_value_num', 'cache_results' => false, 'update_post_term_cache' => false, 'no_found_rows' => true, 'order' => 'DESC'); $top_selling = get_posts($top_selling_args); ?> <div class="table table_current_month"> <p class="sub"><?php _e('Current Month', 'edd'); ?> </p> <table> <tbody> <tr class="first"> <td class="first b"><?php echo edd_currency_filter(edd_format_amount(edd_get_earnings_by_date(null, date('n'), date('Y')))); ?> </td> <td class="t monthly_earnings"><?php _e('Earnings', 'edd'); ?> </td> </tr> <tr> <?php $monthly_sales = edd_get_sales_by_date(null, date('n'), date('Y')); ?> <td class="first b"><?php echo $monthly_sales; ?> </td> <td class="t monthly_sales"><?php echo _n('Sale', 'Sales', $monthly_sales, 'edd'); ?> </td> </tr> </tbody> </table> <p class="label_heading"><?php _e('Last Month', 'edd'); ?> </p> <div> <?php echo __('Earnings', 'edd') . ': <span class="edd_price_label">' . edd_currency_filter(edd_format_amount(edd_get_earnings_by_date(null, date('n') - 1, date('Y')))) . '</span>'; ?> </div> <div> <?php $last_month_sales = edd_get_sales_by_date(null, date('n') - 1, date('Y')); ?> <?php echo _n('Sale', 'Sales', $last_month_sales, 'edd') . ': ' . '<span class="edd_price_label">' . $last_month_sales . '</span>'; ?> </div> </div> <div class="table table_totals"> <p class="sub"><?php _e('Totals', 'edd'); ?> </p> <table> <tbody> <tr class="first"> <td class="b b-earnings"><?php echo edd_currency_filter(edd_format_amount(edd_get_total_earnings())); ?> </td> <td class="last t earnings"><?php _e('Total Earnings', 'edd'); ?> </td> </tr> <tr> <td class="b b-sales"><?php echo edd_get_total_sales(); ?> </td> <td class="last t sales"><?php _e('Total Sales', 'edd'); ?> </td> </tr> </tbody> </table> <?php if ($top_selling) { foreach ($top_selling as $list) { ?> <p class="lifetime_best_selling label_heading"><?php _e('Lifetime Best Selling', 'edd'); ?> </p> <p><span class="lifetime_best_selling_label"><?php echo edd_get_download_sales_stats($list->ID); ?> </span> <a href="<?php echo get_permalink($list->ID); ?> "><?php echo get_the_title($list->ID); ?> </a></p> <?php } } ?> </div> <div style="clear: both"></div> <?php $payments = edd_get_payments(array('number' => 5, 'mode' => 'live', 'orderby' => 'post_date', 'order' => 'DESC', 'user' => null, 'status' => 'publish', 'meta_key' => null)); if ($payments) { ?> <p class="edd_dashboard_widget_subheading"><?php _e('Recent Purchases', 'edd'); ?> </p> <div class="table recent_purchases"> <table> <tbody> <?php foreach ($payments as $payment) { $payment_meta = edd_get_payment_meta($payment->ID); ?> <tr> <td><?php echo get_the_title($payment->ID); ?> - (<?php echo $payment_meta['email']; ?> ) - <span class="edd_price_label"><?php echo edd_currency_filter(edd_format_amount(edd_get_payment_amount($payment->ID))); ?> </span> - <a href="#TB_inline?width=640&inlineId=purchased-files-<?php echo $payment->ID; ?> " class="thickbox" title="<?php printf(__('Purchase Details for Payment #%s', 'edd'), $payment->ID); ?> "><?php _e('View Order Details', 'edd'); ?> </a> <div id="purchased-files-<?php echo $payment->ID; ?> " style="display:none;"> <?php $cart_items = edd_get_payment_meta_cart_details($payment->ID); if (empty($cart_items) || !$cart_items) { $cart_items = maybe_unserialize($payment_meta['downloads']); } ?> <h4><?php echo _n(__('Purchased File', 'edd'), __('Purchased Files', 'edd'), count($cart_items)); ?> </h4> <ul class="purchased-files-list"> <?php if ($cart_items) { foreach ($cart_items as $key => $cart_item) { echo '<li>'; $id = isset($payment_meta['cart_details']) ? $cart_item['id'] : $cart_item; $price_override = isset($payment_meta['cart_details']) ? $cart_item['price'] : null; $user_info = edd_get_payment_meta_user_info($payment->ID); $price = edd_get_download_final_price($id, $user_info, $price_override); echo '<a href="' . admin_url('post.php?post=' . $id . '&action=edit') . '" target="_blank">' . get_the_title($id) . '</a>'; echo ' - '; if (isset($cart_items[$key]['item_number'])) { $price_options = $cart_items[$key]['item_number']['options']; if (isset($price_options['price_id'])) { echo edd_get_price_option_name($id, $price_options['price_id']); echo ' - '; } } echo edd_currency_filter(edd_format_amount($price)); echo '</li>'; } } ?> </ul> <?php $payment_date = strtotime($payment->post_date); ?> <p><?php echo __('Date and Time:', 'edd') . ' ' . date_i18n(get_option('date_format'), $payment_date) . ' ' . date_i18n(get_option('time_format'), $payment_date); ?> <p><?php echo __('Discount used:', 'edd') . ' '; if (isset($user_info['discount']) && $user_info['discount'] != 'none') { echo $user_info['discount']; } else { _e('none', 'edd'); } ?> <p><?php echo __('Total:', 'edd') . ' ' . edd_currency_filter(edd_format_amount(edd_get_payment_amount($payment->ID))); ?> </p> <div class="purcase-personal-details"> <h4><?php _e('Buyer\'s Personal Details:', 'edd'); ?> </h4> <ul> <li><?php echo __('Name:', 'edd') . ' ' . $user_info['first_name'] . ' ' . $user_info['last_name']; ?> </li> <li><?php echo __('Email:', 'edd') . ' ' . $payment_meta['email']; ?> </li> <?php do_action('edd_payment_personal_details_list', $payment_meta, $user_info); ?> </ul> </div> <?php $gateway = edd_get_payment_gateway($payment->ID); if ($gateway) { ?> <div class="payment-method"> <h4><?php _e('Payment Method:', 'edd'); ?> </h4> <span class="payment-method-name"><?php echo edd_get_gateway_admin_label($gateway); ?> </span> </div> <?php } ?> <div class="purchase-key-wrap"> <h4><?php _e('Purchase Key', 'edd'); ?> </h4> <span class="purchase-key"><?php echo $payment_meta['key']; ?> </span> </div> <p><a id="edd-close-purchase-details" class="button-secondary" onclick="tb_remove();" title="<?php _e('Close', 'edd'); ?> "><?php _e('Close', 'edd'); ?> </a></p> </div> </td> </tr> <?php } // end foreach ?> </tbody> </table> </div> <?php } // end if }
/** * Default pre-approval email body for admin * * @since 1.0 */ function edd_pre_approval_emails_get_admin_email_body($payment_id = 0, $payment_data = array()) { global $edd_options; $user_info = maybe_unserialize($payment_data['user_info']); $email = edd_get_payment_user_email($payment_id); if (isset($user_info['id']) && $user_info['id'] > 0) { $user_data = get_userdata($user_info['id']); $name = $user_data->display_name; } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { $name = $user_info['first_name'] . ' ' . $user_info['last_name']; } else { $name = $email; } $gateway = edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true)); $email_body = __('Hello', 'edd-pre-approval-emails') . "\n\n" . __('A new pledge has been made', 'edd-pre-approval-emails') . ".\n\n"; $email_body .= sprintf(__('%s pledged:', 'edd-pre-approval-emails'), edd_get_label_plural()) . "\n\n"; $email_body .= edd_pre_approval_emails_get_download_list($payment_data) . "\n\n"; $email_body .= __('Pledged by: ', 'edd-pre-approval-emails') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n"; $email_body .= __('Amount: ', 'edd-pre-approval-emails') . " " . html_entity_decode(edd_currency_filter(edd_format_amount(edd_get_payment_amount($payment_id))), ENT_COMPAT, 'UTF-8') . "\n"; $email_body .= __('Payment Method: ', 'edd-pre-approval-emails') . " " . $gateway . "\n\n"; $email_body = edd_do_email_tags($email_body, $payment_id); return apply_filters('edd_pledge_notification', wpautop($email_body), $payment_id, $payment_data); }
function meta_box_failed_payments() { global $post; $campaign = atcf_get_campaign($post); $failed_payments = $campaign->failed_payments(); $count = 0; foreach ($failed_payments as $gateways) { foreach ($gateways as $gateway) { $count = $count + count($gateway); } } echo '<p><strong>' . sprintf(_n('%d payment failed to process.', '%d payments failed to process.', $count, 'atcf'), $count) . '</strong> <a href="' . esc_url(add_query_arg(array('page' => 'edd-reports', 'tab' => 'logs', 'view' => 'gateway_errors', 'post_type' => 'download'), admin_url('edit.php'))) . '">' . __('View gateway errors', 'atcf') . '</a>.</p>'; echo '<ul>'; foreach ($failed_payments as $gateway => $payments) { echo '<li><strong>' . edd_get_gateway_admin_label($gateway) . '</strong>'; echo '<ul>'; foreach ($payments['payments'] as $payment) { echo '<li><a href="' . esc_url(admin_url('edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $payment)) . '">#' . $payment . '</a></li>'; } echo '</ul>'; echo '</li>'; } echo '</ul>'; echo '<p><a href="' . wp_nonce_url(add_query_arg(array('action' => 'atcf-collect-funds', 'campaign' => $campaign->ID, 'status' => 'failed'), admin_url()), 'atcf-collect-funds') . '" class="button">' . __('Retry Failed Funds', 'atcf') . '</a></p>'; }
/** * Slackedd Notification Codes * * @since 1.0.0 */ function slackedd_notification($payment_id) { $edd_options = edd_get_settings(); /* Check that the user has all required information added for the plugin to work */ $enable_slack = isset($edd_options['slackedd_enable_notification']) ? $edd_options['slackedd_enable_notification'] : ''; $hide_order_number = isset($edd_options['slackedd_hide_order_number']) ? $edd_options['slackedd_hide_order_number'] : ''; $hide_order_items = isset($edd_options['slackedd_hide_order_items']) ? $edd_options['slackedd_hide_order_items'] : ''; $hide_payment_gateway = isset($edd_options['slackedd_hide_payment_gateway']) ? $edd_options['slackedd_hide_payment_gateway'] : ''; $hide_buyer_information = isset($edd_options['slackedd_hide_buyer_information']) ? $edd_options['slackedd_hide_buyer_information'] : ''; $slack_channel = isset($edd_options['slackedd_channel']) ? $edd_options['slackedd_channel'] : ''; $webhook_url = isset($edd_options['slackedd_webhook_url']) ? $edd_options['slackedd_webhook_url'] : ''; if (!($enable_slack && $slack_channel && $webhook_url)) { return; } $enable_slack = isset($edd_options['slackedd_enable_notification']) ? $edd_options['slackedd_enable_notification'] : ''; $emoji = !empty($edd_options['slackedd_icon_emoji']) ? $edd_options['slackedd_icon_emoji'] : ':moneybag:'; $bot_name = !empty($edd_options['slackedd_bot_name']) ? $edd_options['slackedd_bot_name'] : 'Slackedd'; $order_amount = esc_attr(edd_format_amount(edd_get_payment_amount($payment_id))); $currency_symbol = edd_currency_symbol($payment_meta['currency']); $currency_symbol = html_entity_decode($currency_symbol, ENT_QUOTES, 'UTF-8'); $payment_meta = edd_get_payment_meta($payment_id); $cart_items = edd_get_payment_meta_cart_details($payment_id); $items_sold = ''; $order_id = edd_get_payment_number($payment_id); foreach ($cart_items as $key => $cart_item) { $name = $cart_item['name']; $price = $cart_item['price']; $items_sold .= "*Name:* " . $name . " | *Price:* " . $currency_symbol . "" . $price . " \n"; } $gateway = edd_get_payment_gateway($payment_id); $payment_method = edd_get_gateway_admin_label($gateway); $user_data = $payment_meta['user_info']; /* Display the new sale introduction */ $message = "A new sale has occurred at " . get_bloginfo('name') . " \n\n"; /* Show or hide order number based on user preference in settings page */ if (!$hide_order_number) { $message .= "*Order* <" . get_bloginfo('home') . "/wp-admin/edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=" . $order_id . "|#" . $order_id . "> \n"; } /* Show the order total */ $message .= "*Order Total:* " . $currency_symbol . "" . $order_amount . " \n\n"; /* Show or hide payment gateway based on user preference in settings page */ if (!$hide_payment_gateway) { $message .= "*Payment Method:* " . $payment_method . " \n\n"; } /* Show or hide order items based on user preference in settings page */ if (!$hide_order_items) { $message .= "*" . edd_get_cart_quantity() . " ITEM(S):* \n"; $message .= $items_sold; } /* Show or hide order number based on user preference in settings page */ if (!$hide_buyer_information) { $message .= "\n\n *Customer:* " . $user_data['first_name'] . " " . $user_data['last_name'] . " " . $user_data['email'] . "\n"; } $attachment = array(); $attachment[] = array('color' => 'good', 'fallback' => 'New sale notification of ' . $currency_symbol . '' . $price . ' at ' . get_bloginfo('name'), 'mrkdwn_in' => array('text'), 'text' => $message, 'title' => 'New Sale Notification!'); $payload = array('attachments' => $attachment, 'channel' => $slack_channel, 'icon_emoji' => $emoji, 'username' => $bot_name); $args = array('body' => json_encode($payload), 'timeout' => 30); $response = wp_remote_post($webhook_url, $args); return; }
/** * Payment History Page * * Renders the payment history page contents. * * @access private * @since 1.0 * @return void */ function edd_payment_history_page() { global $edd_options; if (isset($_GET['edd-action']) && $_GET['edd-action'] == 'edit-payment') { include_once EDD_PLUGIN_DIR . '/includes/admin-pages/forms/edit-payment.php'; } else { $current_page = admin_url('edit.php?post_type=download&page=edd-payment-history'); ?> <div class="wrap"> <?php if (isset($_GET['p'])) { $page = $_GET['p']; } else { $page = 1; } $per_page = 20; if (isset($_GET['show']) && $_GET['show'] > 0) { $per_page = intval($_GET['show']); } $total_pages = 1; $offset = $per_page * ($page - 1); $mode = isset($_GET['mode']) ? $_GET['mode'] : 'live'; if (edd_is_test_mode() && !isset($_GET['mode'])) { $mode = 'test'; } $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'ID'; $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; $order_inverse = $order == 'DESC' ? 'ASC' : 'DESC'; $order_class = strtolower($order_inverse); $user = isset($_GET['user']) ? $_GET['user'] : null; $status = isset($_GET['status']) ? $_GET['status'] : 'any'; $meta_key = isset($_GET['meta_key']) ? $_GET['meta_key'] : null; $payments = edd_get_payments(array('offset' => $offset, 'number' => $per_page, 'mode' => $mode, 'orderby' => $orderby, 'order' => $order, 'user' => $user, 'status' => $status, 'meta_key' => $meta_key)); $payment_count = wp_count_posts('edd_payment'); $total_count = $payment_count->publish + $payment_count->pending + $payment_count->refunded + $payment_count->trash; switch ($status) { case 'publish': $current_count = $payment_count->publish; break; case 'pending': $current_count = $payment_count->pending; break; case 'refunded': $current_count = $payment_count->refunded; break; case 'any': $current_count = $total_count; break; } $total_pages = ceil($current_count / $per_page); ?> <h2><?php _e('Payment History', 'edd'); ?> </h2> <?php do_action('edd_payments_page_top'); ?> <ul class="subsubsub"> <li class="all"> <a href="<?php echo remove_query_arg('status'); ?> " <?php echo !isset($_GET['status']) ? 'class="current"' : ''; ?> > <?php _e('All', 'edd'); ?> <span class="count">(<?php echo $total_count; ?> )</span> </a> | </li> <li class="publish"> <a href="<?php echo add_query_arg('status', 'publish'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'publish' ? 'class="current"' : ''; ?> ><?php _e('Completed', 'edd'); ?> <span class="count">(<?php echo $payment_count->publish; ?> )</span></a> | </li> <li class="pending"> <a href="<?php echo add_query_arg('status', 'pending'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'pending' ? 'class="current"' : ''; ?> ><?php _e('Pending', 'edd'); ?> <span class="count">(<?php echo $payment_count->pending; ?> )</span></a> | </li> <li class="refunded"> <a href="<?php echo add_query_arg('status', 'refunded'); ?> " <?php echo isset($_GET['status']) && $_GET['status'] == 'refunded' ? 'class="current"' : ''; ?> ><?php _e('Refunded', 'edd'); ?> <span class="count">(<?php echo $payment_count->refunded; ?> )</span></a> | </li> <?php do_action('edd_payments_page_statuses'); ?> </ul> <ul class="subsubsub edd-export-payments"> <li> <?php _e('Export', 'edd'); ?> : <a href="<?php echo add_query_arg('export', 'csv'); ?> ">CSV</a></li> <?php do_action('edd_payments_page_export_options'); ?> </ul> <form id="payments-filter" action="<?php echo admin_url('edit.php'); ?> " method="get" style="float: right; margin-bottom: 5px;"> <label for="edd-mode"><?php _e('Payment mode', 'edd'); ?> </label> <select name="mode" id="edd-mode"> <option value="live" <?php selected('live', $mode); ?> ><?php _e('Live', 'edd'); ?> </option> <option value="test" <?php selected('test', $mode); ?> ><?php _e('Test', 'edd'); ?> </option> </select> <input type="hidden" name="page" value="edd-payment-history"/> <input type="hidden" name="post_type" value="download"/> <?php if (isset($_GET['user'])) { ?> <input type="hidden" name="user" value="<?php echo $_GET['user']; ?> "/> <?php } ?> <?php if (isset($_GET['status'])) { ?> <input type="hidden" name="status" value="<?php echo $_GET['status']; ?> "/> <?php } ?> <label for="edd_show"><?php _e('Payments per page', 'edd'); ?> </label> <input type="text" class="regular-text" style="width:30px;" id="edd_show" name="show" value="<?php echo isset($_GET['show']) ? $_GET['show'] : ''; ?> "/> <input type="submit" class="button-secondary" value="<?php _e('Show', 'edd'); ?> "/> </form> <?php if (isset($_GET['user'])) { $user = is_numeric($user) ? get_userdata($user) : $user; $user = is_object($user) ? $user->display_name : $user; ?> <p class="clear"><?php echo __('Showing payments for: ', 'edd') . ' ' . $user; ?> - <a href="<?php echo remove_query_arg('user'); ?> "><?php _e('clear', 'edd'); ?> </a></div> <?php } ?> <table class="wp-list-table widefat fixed posts edd-payments"> <thead> <tr> <th style="width: 60px;" class="manage-column column-title sortable <?php echo $order_class; echo $orderby == 'ID' ? ' sorted' : ''; ?> "> <a href="<?php echo add_query_arg(array('orderby' => 'ID', 'order' => $order_inverse)); ?> " title="<?php _e('ID', 'edd'); ?> "><span><?php _e('ID', 'edd'); ?> </span> <span class="sorting-indicator"></span></a> </th> <th style="width: 250px;"><?php _e('Email', 'edd'); ?> </th> <th><?php _e('Products', 'edd'); ?> </th> <th> <a href="<?php echo add_query_arg(array('meta_key' => '_edd_payment_total', 'order' => $order_inverse, 'orderby' => 'meta_value_num')); ?> " title="<?php _e('Price', 'edd'); ?> "><span><?php _e('Price', 'edd'); ?> </span> <span class="sorting-indicator"></span></a> </th> <th class="manage-column column-title sortable <?php echo $order_class; echo $orderby == 'Date' ? ' sorted' : ''; ?> "> <a href="<?php echo add_query_arg(array('orderby' => 'post_date', 'order' => $order_inverse)); ?> " title="<?php _e('Date', 'edd'); ?> "><span><?php _e('Date', 'edd'); ?> </span> <span class="sorting-indicator"></span></a> </th> <th><?php _e('User', 'edd'); ?> </span></th> <th class="manage-column column-title sortable <?php echo $order_class; echo $orderby == 'Status' ? ' sorted' : ''; ?> "> <a href="<?php echo add_query_arg(array('orderby' => 'post_status', 'order' => $order_inverse)); ?> " title="<?php _e('Status', 'edd'); ?> "><span><?php _e('Status', 'edd'); ?> </span> <span class="sorting-indicator"></span></a> </th> </tr> </thead> <tfoot> <tr> <th style="width: 40px;"><?php _e('ID', 'edd'); ?> </th> <th style="width: 250px;"><?php _e('Email', 'edd'); ?> </th> <th><?php _e('Products', 'edd'); ?> </th> <th><?php _e('Price', 'edd'); ?> </th> <th><?php _e('Date', 'edd'); ?> </th> <th><?php _e('User', 'edd'); ?> </th> <th><?php _e('Status', 'edd'); ?> </th> </tr> </tfoot> <tbody> <?php if ($payments) { $i = 0; foreach ($payments as $payment) { ?> <?php $payment_meta = get_post_meta($payment->ID, '_edd_payment_meta', true); $user_info = maybe_unserialize($payment_meta['user_info']); $classes = array(); $classes[] = edd_is_odd($i) ? 'alternate' : ''; $payment_classes = get_post_class(apply_filters('edd_payment_row_classes', $classes), $payment->ID); ?> <tr class="edd_payment <?php echo implode(' ', $payment_classes); ?> "> <td> <?php echo $payment->ID; ?> </td> <td> <?php echo $payment_meta['email']; ?> <div class="row-actions"> <?php $row_actions = array('edit' => '<a href="' . add_query_arg(array('edd-action' => 'edit-payment', 'purchase_id' => $payment->ID)) . '">' . __('Edit', 'edd') . '</a>', 'email_links' => edd_is_payment_complete($payment->ID) ? '<a href="' . add_query_arg(array('edd-action' => 'email_links', 'purchase_id' => $payment->ID)) . '">' . __('Resend Purchase Receipt', 'edd') . '</a>' : NULL, 'delete' => '<a href="' . wp_nonce_url(add_query_arg(array('edd-action' => 'delete_payment', 'purchase_id' => $payment->ID)), 'edd_payment_nonce') . '">' . __('Delete', 'edd') . '</a>'); $row_actions = apply_filters('edd_payment_row_actions', $row_actions, $payment); $action_count = count($row_actions); $i = 1; foreach ($row_actions as $key => $action) { if ($action_count == $i) { $sep = ''; } else { $sep = ' | '; } echo !is_null($action) ? '<span class="' . $key . '">' . $action . '</span>' . $sep : ''; $i++; } ?> </div> </td> <td><a href="#TB_inline?width=640&inlineId=purchased-files-<?php echo $payment->ID; ?> " class="thickbox" title="<?php printf(__('Purchase Details for Payment #%s', 'edd'), $payment->ID); ?> "><?php _e('View Order Details', 'edd'); ?> </a> <div id="purchased-files-<?php echo $payment->ID; ?> " style="display:none;"> <?php $downloads = isset($payment_meta['cart_details']) ? maybe_unserialize($payment_meta['cart_details']) : false; if (empty($downloads) || !$downloads) { $downloads = maybe_unserialize($payment_meta['downloads']); } ?> <h4><?php echo _n(__('Purchased File', 'edd'), __('Purchased Files', 'edd'), count($downloads)); ?> </h4> <ul class="purchased-files-list"> <?php if ($downloads) { foreach ($downloads as $key => $download) { echo '<li>'; // retrieve the ID of the download $id = isset($payment_meta['cart_details']) ? $download['id'] : $download; // if download has variable prices, override the default price $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null; $user_info = unserialize($payment_meta['user_info']); // calculate the final price $price = edd_get_download_final_price($id, $user_info, $price_override); // show name of download echo '<a href="' . admin_url('post.php?post=' . $id . '&action=edit') . '" target="_blank">' . get_the_title($id) . '</a>'; echo ' - '; if (isset($downloads[$key]['item_number'])) { $price_options = $downloads[$key]['item_number']['options']; if (isset($price_options['price_id'])) { echo edd_get_price_option_name($id, $price_options['price_id']); echo ' - '; } } // show price echo edd_currency_filter($price); echo '</li>'; } } ?> </ul> <p><?php echo __('Discount used:', 'edd') . ' '; if (isset($user_info['discount']) && $user_info['discount'] != 'none') { echo $user_info['discount']; } else { _e('none', 'edd'); } ?> <p><?php echo __('Total:', 'edd') . ' ' . edd_currency_filter($payment_meta['amount']); ?> </p> <div class="purcase-personal-details"> <h4><?php _e('Buyer\'s Personal Details:', 'edd'); ?> </h4> <ul> <li><?php echo __('Name:', 'edd') . ' ' . $user_info['first_name'] . ' ' . $user_info['last_name']; ?> </li> <li><?php echo __('Email:', 'edd') . ' ' . $payment_meta['email']; ?> </li> <?php do_action('edd_payment_personal_details_list', $payment_meta, $user_info); ?> </ul> </div> <?php $gateway = get_post_meta($payment->ID, '_edd_payment_gateway', true); if ($gateway) { ?> <div class="payment-method"> <h4><?php _e('Payment Method:', 'edd'); ?> </h4> <span class="payment-method-name"><?php echo edd_get_gateway_admin_label($gateway); ?> </span> </div> <?php } ?> <div class="purchase-key-wrap"> <h4><?php _e('Purchase Key', 'edd'); ?> </h4> <span class="purchase-key"><?php echo $payment_meta['key']; ?> </span> </div> <p><a id="edd-close-purchase-details" class="button-secondary" onclick="tb_remove();" title="<?php _e('Close', 'edd'); ?> "><?php _e('Close', 'edd'); ?> </a></p> </div> </td> <td style="text-transform:uppercase;"><?php echo edd_currency_filter($payment_meta['amount']); ?> </td> <td><?php echo date(apply_filters('edd_payments_page_date_format', get_option('date_format')), strtotime($payment->post_date)); ?> </td> <td> <?php $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email']; ?> <a href="<?php echo remove_query_arg('p', add_query_arg('user', $user_id)); ?> "> <?php if (is_numeric($user_id)) { $user = get_user_by('id', $user_id); echo is_object($user) ? $user->display_name : __('guest', 'edd'); } else { echo __('guest', 'edd'); } ?> </a> </td> <td><?php echo edd_get_payment_status($payment, true); ?> </td> </tr> <?php $i++; } } else { ?> <tr><td colspan="7"><?php _e('No payments recorded yet', 'edd'); ?> </td></tr> <?php } ?> </table> <div class="tablenav"> <div class="left edd-total-earnings"> <p><?php _e('Total Earnings:', 'edd'); ?> <strong><?php echo edd_get_total_earnings(); ?> </strong></p> <?php do_action('edd_payments_page_earnings'); ?> </div> <?php if ($total_pages > 1) { ?> <div class="tablenav-pages alignright"> <?php $query_string = $_SERVER['QUERY_STRING']; $base = 'edit.php?' . remove_query_arg('p', $query_string) . '%_%'; echo paginate_links(array('base' => $base, 'format' => '&p=%#%', 'prev_text' => '« ' . __('Previous', 'edd'), 'next_text' => __('Next', 'edd') . ' »', 'total' => $total_pages, 'current' => $page, 'end_size' => 1, 'mid_size' => 5)); ?> </div> <?php } ?> </div><!--end .tablenav--> <?php do_action('edd_payments_page_bottom'); ?> </div><!--end wrap--> <?php } }
/** * Get the Export Data * * @access public * @since 2.4 * @global object $wpdb Used to query the database using the WordPress * Database API * @return array $data The data for the CSV file */ public function get_data() { global $wpdb; $data = array(); $args = array('number' => 30, 'page' => $this->step, 'status' => $this->status, 'order' => 'ASC', 'orderby' => 'date'); if (!empty($this->start) || !empty($this->end)) { $args['date_query'] = array(array('after' => date('Y-n-d 00:00:00', strtotime($this->start)), 'before' => date('Y-n-d 23:59:59', strtotime($this->end)), 'inclusive' => true)); } //echo json_encode($args ); exit; $payments = edd_get_payments($args); if ($payments) { foreach ($payments as $payment) { $payment = new EDD_Payment($payment->ID); $payment_meta = $payment->payment_meta; $user_info = $payment->user_info; $downloads = $payment->cart_details; $total = $payment->total; $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email']; $products = ''; $products_raw = ''; $skus = ''; if ($downloads) { foreach ($downloads as $key => $download) { // Download ID $id = isset($payment_meta['cart_details']) ? $download['id'] : $download; $qty = isset($download['quantity']) ? $download['quantity'] : 1; if (isset($download['price'])) { $price = $download['price']; } else { // If the download has variable prices, override the default price $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null; $price = edd_get_download_final_price($id, $user_info, $price_override); } $download_tax = isset($download['tax']) ? $download['tax'] : 0; /* Set up verbose product column */ $products .= html_entity_decode(get_the_title($id)); if ($qty > 1) { $products .= html_entity_decode(' (' . $qty . ')'); } $products .= ' - '; if (edd_use_skus()) { $sku = edd_get_download_sku($id); if (!empty($sku)) { $skus .= $sku; } } if (isset($downloads[$key]['item_number']) && isset($downloads[$key]['item_number']['options'])) { $price_options = $downloads[$key]['item_number']['options']; if (isset($price_options['price_id']) && !is_null($price_options['price_id'])) { $products .= html_entity_decode(edd_get_price_option_name($id, $price_options['price_id'], $payment->ID)) . ' - '; } } $products .= html_entity_decode(edd_currency_filter(edd_format_amount($price))); if ($key != count($downloads) - 1) { $products .= ' / '; if (edd_use_skus()) { $skus .= ' / '; } } /* Set up raw products column - Nothing but product names */ $products_raw .= html_entity_decode(get_the_title($id)) . '|' . $price . '{' . $download_tax . '}'; if ($key != count($downloads) - 1) { $products_raw .= ' / '; } } } if (is_numeric($user_id)) { $user = get_userdata($user_id); } else { $user = false; } $data[] = array('id' => $payment->ID, 'seq_id' => $payment->number, 'email' => $payment_meta['email'], 'customer_id' => $payment->customer_id, 'first' => $user_info['first_name'], 'last' => $user_info['last_name'], 'address1' => isset($user_info['address']['line1']) ? $user_info['address']['line1'] : '', 'address2' => isset($user_info['address']['line2']) ? $user_info['address']['line2'] : '', 'city' => isset($user_info['address']['city']) ? $user_info['address']['city'] : '', 'state' => isset($user_info['address']['state']) ? $user_info['address']['state'] : '', 'country' => isset($user_info['address']['country']) ? $user_info['address']['country'] : '', 'zip' => isset($user_info['address']['zip']) ? $user_info['address']['zip'] : '', 'products' => $products, 'products_raw' => $products_raw, 'skus' => $skus, 'amount' => html_entity_decode(edd_format_amount($total)), 'tax' => html_entity_decode(edd_format_amount(edd_get_payment_tax($payment->ID, $payment_meta))), 'discount' => isset($user_info['discount']) && $user_info['discount'] != 'none' ? $user_info['discount'] : __('none', 'easy-digital-downloads'), 'gateway' => edd_get_gateway_admin_label(get_post_meta($payment->ID, '_edd_payment_gateway', true)), 'trans_id' => $payment->transaction_id, 'key' => $payment_meta['key'], 'date' => $payment->date, 'user' => $user ? $user->display_name : __('guest', 'easy-digital-downloads'), 'currency' => $payment->currency, 'ip' => $payment->ip, 'mode' => $payment->get_meta('_edd_payment_mode', true), 'status' => 'publish' === $payment->status ? 'complete' : $payment->status); } $data = apply_filters('edd_export_get_data', $data); $data = apply_filters('edd_export_get_data_' . $this->export_type, $data); return $data; } return false; }
/** * Sends the Admin Sale Notification Email * * @since 1.4.2 * @param int $payment_id Payment ID (default: 0) * @param array $payment_data Payment Meta and Data * @return void */ function edd_admin_email_notice($payment_id = 0, $payment_data = array()) { /* Send an email notification to the admin */ $admin_email = edd_get_admin_notice_emails(); $user_info = maybe_unserialize($payment_data['user_info']); if (isset($user_info['id']) && $user_info['id'] > 0) { $user_data = get_userdata($user_info['id']); $name = $user_data->display_name; } elseif (isset($user_info['first_name']) && isset($user_info['last_name'])) { $name = $user_info['first_name'] . ' ' . $user_info['last_name']; } else { $name = $user_info['email']; } $admin_subject = apply_filters('edd_admin_purchase_notification_subject', __('New download purchase', 'edd'), $payment_id, $payment_data); $admin_message = __('Hello', 'edd') . "\n\n" . sprintf(__('A %s purchase has been made', 'edd'), edd_get_label_plural()) . ".\n\n"; $admin_message .= sprintf(__('%s sold:', 'edd'), edd_get_label_plural()) . "\n\n"; $download_list = ''; $downloads = maybe_unserialize($payment_data['downloads']); if (is_array($downloads)) { foreach ($downloads as $download) { $id = isset($payment_data['cart_details']) ? $download['id'] : $download; $title = get_the_title($id); if (isset($download['options'])) { if (isset($download['options']['price_id'])) { $title .= ' - ' . edd_get_price_option_name($id, $download['options']['price_id'], $payment_id); } } $download_list .= html_entity_decode($title, ENT_COMPAT, 'UTF-8') . "\n"; } } $gateway = edd_get_gateway_admin_label(get_post_meta($payment_id, '_edd_payment_gateway', true)); $admin_message .= $download_list . "\n"; $admin_message .= __('Purchased by: ', 'edd') . " " . html_entity_decode($name, ENT_COMPAT, 'UTF-8') . "\n"; $admin_message .= __('Amount: ', 'edd') . " " . html_entity_decode(edd_currency_filter(edd_format_amount($payment_data['amount'])), ENT_COMPAT, 'UTF-8') . "\n\n"; $admin_message .= __('Payment Method: ', 'edd') . " " . $gateway . "\n\n"; $admin_message .= __('Thank you', 'edd'); $admin_message = apply_filters('edd_admin_purchase_notification', $admin_message, $payment_id, $payment_data); $admin_headers = apply_filters('edd_admin_purchase_notification_headers', array(), $payment_id, $payment_data); $admin_attachments = apply_filters('edd_admin_purchase_notification_attachments', array(), $payment_id, $payment_data); wp_mail($admin_email, $admin_subject, $admin_message, $admin_headers, $admin_attachments); }
function edd_export_payment_history() { global $edd_options; if (!isset($_GET['export'])) { return; } // get out quick if not required. $mode = isset($_GET['mode']) ? $_GET['mode'] : 'live'; if (edd_is_test_mode() && !isset($_GET['mode'])) { $mode = 'test'; } $orderby = isset($_GET['orderby']) ? $_GET['orderby'] : 'ID'; $order = isset($_GET['order']) ? $_GET['order'] : 'DESC'; $order_inverse = $order == 'DESC' ? 'ASC' : 'DESC'; $order_class = strtolower($order_inverse); $user = isset($_GET['user']) ? $_GET['user'] : null; $status = isset($_GET['status']) ? $_GET['status'] : null; $export = isset($_GET['export']) ? $_GET['export'] : null; if ($export == 'csv') { // extensible for other formats in future header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=edd-payment-history-' . date('m-d-Y') . '.csv'); header("Pragma: no-cache"); header("Expires: 0"); $payments = edd_get_payments(array('offset' => 0, 'number' => -1, 'mode' => $mode, 'orderby' => $orderby, 'order' => $order, 'user' => $user, 'status' => $status)); if ($payments) { $i = 0; echo '"' . __('ID', 'edd') . '",'; echo '"' . __('Email', 'edd') . '",'; echo '"' . __('First Name', 'edd') . '",'; echo '"' . __('Last Name', 'edd') . '",'; echo '"' . __('Products', 'edd') . '",'; echo '"' . __('Discounts,', 'edd') . '",'; echo '"' . __('Amount paid', 'edd') . '",'; echo '"' . __('Payment method', 'edd') . '",'; echo '"' . __('Key', 'edd') . '",'; echo '"' . __('Date', 'edd') . '",'; echo '"' . __('User', 'edd') . '",'; echo '"' . __('Status', 'edd') . '"'; echo "\r\n"; foreach ($payments as $payment) { $payment_meta = edd_get_payment_meta($payment->ID); $user_info = maybe_unserialize($payment_meta['user_info']); echo '"' . $payment->ID . '",'; echo '"' . $payment_meta['email'] . '",'; echo '"' . $user_info['first_name'] . '",'; echo '"' . $user_info['last_name'] . '",'; $downloads = isset($payment_meta['cart_details']) ? maybe_unserialize($payment_meta['cart_details']) : false; if (empty($downloads) || !$downloads) { $downloads = maybe_unserialize($payment_meta['downloads']); } if ($downloads) { foreach ($downloads as $key => $download) { // retrieve the ID of the download $id = isset($payment_meta['cart_details']) ? $download['id'] : $download; // if download has variable prices, override the default price $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null; $user_info = unserialize($payment_meta['user_info']); // calculate the final price $price = edd_get_download_final_price($id, $user_info, $price_override); // show name of download echo get_the_title($id); echo ' - '; if (isset($downloads[$key]['item_number'])) { $price_options = $downloads[$key]['item_number']['options']; if (isset($price_options['price_id'])) { echo edd_get_price_option_name($id, $price_options['price_id']); echo ' - '; } } echo html_entity_decode(edd_currency_filter($price)); if ($key != count($downloads) - 1) { echo ' / '; } } echo ','; } if (isset($user_info['discount']) && $user_info['discount'] != 'none') { echo '"' . $user_info['discount'] . '",'; } else { echo '"' . __('none', 'edd') . '",'; } echo '"' . html_entity_decode(edd_currency_filter($payment_meta['amount'])) . '",'; $gateway = get_post_meta($payment->ID, '_edd_payment_gateway', true); if ($gateway) { echo '"' . edd_get_gateway_admin_label($gateway) . '",'; } else { echo '"' . __('none', 'edd') . '",'; } echo '"' . $payment_meta['key'] . '",'; echo '"' . date(get_option('date_format'), strtotime($payment->post_date)) . '",'; $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email']; echo '"'; echo is_numeric($user_id) ? get_user_by('id', $user_id)->display_name : __('guest', 'edd'); echo '",'; echo '"' . edd_get_payment_status($payment, true) . '"'; echo "\r\n"; $i++; } } else { echo __('No payments recorded yet', 'edd'); } } die; }
/** * Export all Payment History to CSV * * @access private * @since 1.2 * @return void */ function edd_export_payment_history() { global $edd_options; ignore_user_abort(true); if (!edd_is_func_disabled('set_time_limit') && !ini_get('safe_mode')) { set_time_limit(0); } $mode = edd_is_test_mode() ? 'test' : 'live'; header('Content-Type: text/csv; charset=utf-8'); header('Content-Disposition: attachment; filename=edd-payment-history-' . date('m-d-Y') . '.csv'); header("Pragma: no-cache"); header("Expires: 0"); $payments = edd_get_payments(array('offset' => 0, 'number' => -1, 'mode' => $mode)); if ($payments) { $i = 0; echo '"' . __('ID', 'edd') . '",'; echo '"' . __('Email', 'edd') . '",'; echo '"' . __('First Name', 'edd') . '",'; echo '"' . __('Last Name', 'edd') . '",'; echo '"' . __('Products', 'edd') . '",'; echo '"' . __('Discounts,', 'edd') . '",'; echo '"' . __('Amount paid', 'edd') . '",'; if (edd_use_taxes()) { echo '"' . __('Amount taxed', 'edd') . '",'; } echo '"' . __('Payment method', 'edd') . '",'; echo '"' . __('Key', 'edd') . '",'; echo '"' . __('Date', 'edd') . '",'; echo '"' . __('User', 'edd') . '",'; echo '"' . __('Status', 'edd') . '"'; echo "\r\n"; foreach ($payments as $payment) { $payment_meta = edd_get_payment_meta($payment->ID); $user_info = edd_get_payment_meta_user_info($payment->ID); echo '"' . $payment->ID . '",'; echo '"' . $payment_meta['email'] . '",'; echo '"' . $user_info['first_name'] . '",'; echo '"' . $user_info['last_name'] . '",'; $downloads = edd_get_payment_meta_cart_details($payment->ID); if (empty($downloads) || !$downloads) { $downloads = maybe_unserialize($payment_meta['downloads']); } if ($downloads) { foreach ($downloads as $key => $download) { // Download ID $id = isset($payment_meta['cart_details']) ? $download['id'] : $download; // If the download has variable prices, override the default price $price_override = isset($payment_meta['cart_details']) ? $download['price'] : null; $user_info = unserialize($payment_meta['user_info']); $price = edd_get_download_final_price($id, $user_info, $price_override); // Display the Downoad Name echo '"' . get_the_title($id); echo ' - '; if (isset($downloads[$key]['item_number'])) { $price_options = $downloads[$key]['item_number']['options']; if (isset($price_options['price_id'])) { echo edd_get_price_option_name($id, $price_options['price_id']); echo ' - '; } } echo html_entity_decode(edd_currency_filter($price)); if ($key != count($downloads) - 1) { echo ' / '; } } echo '",'; } if (isset($user_info['discount']) && $user_info['discount'] != 'none') { echo '"' . $user_info['discount'] . '",'; } else { echo '"' . __('none', 'edd') . '",'; } echo '"' . html_entity_decode(edd_currency_filter(edd_format_amount($payment_meta['amount']))) . '",'; if (edd_use_taxes()) { echo '"' . html_entity_decode(edd_payment_tax($payment->ID, $payment_meta)) . '",'; } $gateway = get_post_meta($payment->ID, '_edd_payment_gateway', true); if ($gateway) { echo '"' . edd_get_gateway_admin_label($gateway) . '",'; } else { echo '"' . __('none', 'edd') . '",'; } echo '"' . $payment_meta['key'] . '",'; echo '"' . date_i18n(get_option('date_format'), strtotime($payment->post_date)) . '",'; $user_id = isset($user_info['id']) && $user_info['id'] != -1 ? $user_info['id'] : $user_info['email']; echo '"' . is_numeric($user_id) ? get_user_by('id', $user_id)->display_name : __('guest', 'edd') . '",'; echo '"' . edd_get_payment_status($payment, true) . '"'; echo "\r\n"; $i++; } } else { echo __('No payments recorded yet', 'edd'); } die; }
/** * Render the details column * * @access private * @since 1.3.4 * @return string */ function column_details($item) { $details = "<a href='#TB_inline?width=640&inlineId=purchased-files-" . $item['ID'] . "' class='thickbox' title='" . sprintf(__('Purchase Details for Payment #%s', 'edd'), $item['ID']) . "'>" . __('View Order Details', 'edd') . "</a>"; ob_start(); ?> <div id="purchased-files-<?php echo $item['ID']; ?> " style="display: none;"> <?php $payment_meta = edd_get_payment_meta($item['ID']); $cart_items = isset($payment_meta['cart_details']) ? maybe_unserialize($payment_meta['cart_details']) : false; if (empty($cart_items) || !$cart_items) { $cart_items = maybe_unserialize($payment_meta['downloads']); } ?> <h4><?php echo _n(__('Purchased File', 'edd'), __('Purchased Files', 'edd'), count($cart_items)); ?> </h4> <ul class="purchased-files-list"> <?php if ($cart_items) { foreach ($cart_items as $key => $cart_item) { echo '<li>'; // Retrieve the ID of the download $id = isset($payment_meta['cart_details']) ? $cart_item['id'] : $cart_item; // If download has variable prices, override the default price $price_override = isset($payment_meta['cart_details']) ? $cart_item['price'] : null; // Get the user information $user_info = edd_get_payment_meta_user_info($item['ID']); // Calculate the final item price $price = edd_get_download_final_price($id, $user_info, $price_override); // Show name of download echo '<a href="' . admin_url('post.php?post=' . $id . '&action=edit') . '" target="_blank">' . get_the_title($id) . '</a>'; echo ' - '; if (isset($cart_items[$key]['item_number'])) { $price_options = $cart_items[$key]['item_number']['options']; if (isset($price_options['price_id'])) { echo edd_get_price_option_name($id, $price_options['price_id']); echo ' - '; } } // Show the price echo edd_currency_filter(edd_format_amount($price)); echo '</li>'; } } ?> </ul> <?php $payment_date = strtotime($item['date']); ?> <p><?php echo __('Date and Time:', 'edd') . ' ' . date_i18n(get_option('date_format'), $payment_date) . ' ' . date_i18n(get_option('time_format'), $payment_date); ?> <p><?php echo __('Discount used:', 'edd') . ' '; if (isset($user_info['discount']) && $user_info['discount'] != 'none') { echo $user_info['discount']; } else { _e('none', 'edd'); } ?> <p><?php echo __('Total:', 'edd') . ' ' . edd_currency_filter(edd_format_amount(edd_get_payment_amount($item['ID']))); ?> </p> <div class="purcase-personal-details"> <h4><?php _e('Buyer\'s Personal Details:', 'edd'); ?> </h4> <ul> <li><?php echo __('Name:', 'edd') . ' ' . $user_info['first_name'] . ' ' . $user_info['last_name']; ?> </li> <li><?php echo __('Email:', 'edd') . ' ' . $payment_meta['email']; ?> </li> <?php do_action('edd_payment_personal_details_list', $payment_meta, $user_info); ?> </ul> </div> <div class="payment-notes"> <h4><?php _e('Payment Notes', 'edd'); ?> </h4> <?php $notes = edd_get_payment_notes($item['ID']); if (!empty($notes)) { echo '<ul id="payment-notes">'; foreach ($notes as $note) { if (!empty($note->user_id)) { $user = get_userdata($note->user_id); $user = $user->display_name; } else { $user = __('EDD Bot', 'edd'); } echo '<div class="edd-payment-note"><strong>' . $user . '</strong> <em>' . $note->comment_date . '</em> —' . $note->comment_content . '</div>'; } echo '</ul>'; } else { echo '<p>' . __('No payment notes', 'edd') . '</p>'; } ?> </div> <?php $gateway = edd_get_payment_gateway($item['ID']); if ($gateway) { ?> <div class="payment-method"> <h4><?php _e('Payment Method:', 'edd'); ?> </h4> <span class="payment-method-name"><?php echo edd_get_gateway_admin_label($gateway); ?> </span> </div> <?php } ?> <div class="purchase-key-wrap"> <h4><?php _e('Purchase Key', 'edd'); ?> </h4> <span class="purchase-key"><?php echo $payment_meta['key']; ?> </span> </div> <p><a id="edd-close-purchase-details" class="button-secondary" onclick="tb_remove();" title="<?php _e('Close', 'edd'); ?> "><?php _e('Close', 'edd'); ?> </a></p> </div> <?php $details .= ob_get_clean(); return $details; }