/** * Trigger the tickets email * * @param int $payment_id * * @return string */ public function trigger($payment_id = 0) { global $edd_options; $payment_data = edd_get_payment_meta($payment_id); $user_id = edd_get_payment_user_id($payment_id); $user_info = maybe_unserialize($payment_data['user_info']); $email = edd_get_payment_user_email($payment_id); if (isset($user_id) && $user_id > 0) { $user_data = get_userdata($user_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; } $message = $this->get_content_html($payment_id); $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 = !empty($edd_options['ticket_subject']) ? wp_strip_all_tags($edd_options['ticket_subject'], true) : $this->default_subject; $subject = apply_filters('edd_ticket_receipt_subject', $subject, $payment_id); $subject = edd_email_template_tags($subject, $payment_data, $payment_id); $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 .= "Content-Type: text/html; charset=utf-8\r\n"; $headers = apply_filters('edd_ticket_receipt_headers', $headers, $payment_id, $payment_data); // Allow add-ons to add file attachments $attachments = apply_filters('edd_ticket_receipt_attachments', array(), $payment_id, $payment_data); if (apply_filters('edd_email_ticket_receipt', true)) { wp_mail($email, $subject, $message, $headers, $attachments); } }
public function filter_reminder_template_tags($text = '', $license_id = 0) { $payment_id = get_post_meta($license_id, '_edd_sl_payment_id', true); $user_info = edd_get_payment_meta_user_info($payment_id); $user_id = edd_get_payment_user_id($payment_id); // Retrieve the customer name if ($user_id) { $user_data = get_userdata($user_id); $customer_name = $user_data->display_name; } elseif (isset($user_info['first_name'])) { $customer_name = $user_info['first_name']; } else { $customer_name = $user_info['email']; } $license_key = edd_software_licensing()->get_license_key($license_id); $download_id = get_post_meta($license_id, '_edd_sl_download_id', true); $product_name = get_the_title($download_id); $expiration = edd_software_licensing()->get_license_expiration($license_id); $expiration = date(get_option('date_format'), $expiration); $discount = edd_sl_get_renewal_discount_percentage($license_id); $renewal_link = apply_filters('edd_sl_renewal_link', edd_get_checkout_uri(array('edd_license_key' => $license_key, 'download_id' => $download_id))); $text = str_replace('{name}', $customer_name, $text); $text = str_replace('{license_key}', $license_key, $text); $text = str_replace('{product_name}', $product_name, $text); $text = str_replace('{expiration}', $expiration, $text); if (!empty($discount)) { $text = str_replace('{renewal_discount}', $discount . '%', $text); } $text = str_replace('{renewal_link}', $renewal_link, $text); return $text; }
/** * Add member to an RCP subscription level when they purchase a specific product * */ function pw_edd_add_customer_to_level($payment_id = 0) { $user_id = edd_get_payment_user_id($payment_id); if ($user_id <= 0) { return; } $downloads = edd_get_payment_meta_downloads($payment_id); if ($downloads) { $level = false; foreach ($downloads as $download) { // Set the subscription level based on the product ID(s) purchased switch ($download['id']) { case 45: // Set the subscription level to add the user to $level = 4; break; case 742: break; } } if (!empty($level) && function_exists('rcp_set_status')) { // Give user one month of access $expiration = date('Y-m-d H:i:s', strtotime('+1 month')); update_user_meta($user_id, 'rcp_subscription_level', $level); update_user_meta($user_id, 'rcp_expiration', $expiration); rcp_set_status($user_id, 'active'); } } }
function ao_edd_set_customer_role($payment_id) { $email = edd_get_payment_user_email($payment_id); $downloads = edd_get_payment_meta_downloads($payment_id); $user_id = edd_get_payment_user_id($payment_id); if ($user_id) { $user = new WP_User($user_id); // Add role $user->add_role('buyer'); } }
function pw_edd_give_subscription_on_purchase($payment_id) { $user_id = edd_get_payment_user_id($payment_id); if (empty($user_id) || $user_id < 1) { return; } if (!class_exists('EDD_Recurring_Customer')) { return; } $customer = new EDD_Recurring_Customer(); $customer->set_as_subscriber($user_id); $customer->set_customer_payment_id($payment_id); $customer->set_customer_status($user_id, 'active'); $customer->set_customer_expiration($user_id, strtotime('+1 year')); }
/** * Determines the receipt visibility status * * @return bool Whether the receipt is visible or not. */ function edd_can_view_receipt($payment_key = '') { $return = false; if (empty($payment_key)) { return $return; } global $edd_receipt_args; $edd_receipt_args['id'] = edd_get_purchase_id_by_key($payment_key); $user_id = (int) edd_get_payment_user_id($edd_receipt_args['id']); $payment_meta = edd_get_payment_meta($edd_receipt_args['id']); if (is_user_logged_in()) { if ($user_id === (int) get_current_user_id()) { $return = true; } elseif (wp_get_current_user()->user_email === edd_get_payment_user_email($edd_receipt_args['id'])) { $return = true; } elseif (current_user_can('view_shop_sensitive_data')) { $return = true; } } $session = edd_get_purchase_session(); if (!empty($session) && !is_user_logged_in()) { if ($session['purchase_key'] === $payment_meta['key']) { $return = true; } } return (bool) apply_filters('edd_can_view_receipt', $return, $payment_key); }
/** * Add upsells to order details screen * * @since 1.0 */ function edd_csau_view_order_details_upsells($payment_id) { $item = get_post($payment_id); $payment_meta = edd_get_payment_meta($payment_id); $cart_items = edd_get_payment_meta_cart_details($payment_id); $user_info = edd_get_payment_meta_user_info($payment_id); $user_id = edd_get_payment_user_id($payment_id); $payment_date = strtotime($item->post_date); if (!get_post_meta($payment_id, '_edd_payment_upsell_total', true)) { return; } ?> <div id="edd-purchased-files" class="postbox"> <h3 class="hndle"><?php _e('Upsells included with this payment', 'edd-csau'); ?> </h3> <div class="inside"> <table class="wp-list-table widefat fixed" cellspacing="0"> <tbody id="the-list"> <?php if ($cart_items) { $i = 0; foreach ($cart_items as $key => $cart_item) { $id = isset($payment_meta['cart_details']) ? $cart_item['id'] : $cart_item; $price_override = isset($payment_meta['cart_details']) ? $cart_item['price'] : null; $price = edd_get_download_final_price($id, $user_info, $price_override); if (!isset($cart_item['item_number']['upsell'])) { continue; } ?> <tr class="<?php if ($i % 2 == 0) { echo 'alternate'; } ?> "> <td class="name column-name"> <?php echo '<a href="' . admin_url('post.php?post=' . $id . '&action=edit') . '">' . get_the_title($id) . '</a>'; 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'], $payment_id); } } ?> </td> </tr> <?php $i++; } } ?> </tbody> </table> </div> </div> <?php }
/** * Processes the "end of term (eot)" IPN notice * * @since 1.0 * @return void */ public static function process_paypal_subscr_eot($ipn_data) { $user_id = edd_get_payment_user_id($ipn_data['custom']); // set the customer status EDD_Recurring_Customer::set_customer_status($user_id, 'expired'); }
/** * Receipt Shortcode * * Shows an order receipt. * * @since 1.4 * @param array $atts Shortcode attributes * @param string $content * @return string */ function edd_receipt_shortcode($atts, $content = null) { global $edd_receipt_args; $edd_receipt_args = shortcode_atts(array('error' => __('Sorry, trouble retrieving payment receipt.', 'edd'), 'price' => true, 'discount' => true, 'products' => true, 'date' => true, 'notes' => true, 'payment_key' => false, 'payment_method' => true, 'payment_id' => true), $atts, 'edd_receipt'); $session = edd_get_purchase_session(); if (isset($_GET['payment_key'])) { $payment_key = urldecode($_GET['payment_key']); } elseif ($edd_receipt_args['payment_key']) { $payment_key = $edd_receipt_args['payment_key']; } else { if ($session) { $payment_key = $session['purchase_key']; } } // No key found if (!isset($payment_key)) { return $edd_receipt_args['error']; } $edd_receipt_args['id'] = edd_get_purchase_id_by_key($payment_key); $customer_id = edd_get_payment_user_id($edd_receipt_args['id']); /* * Check if the user has permission to view the receipt * * If user is logged in, user ID is compared to user ID of ID stored in payment meta * * Or if user is logged out and purchase was made as a guest, the purchase session is checked for * * Or if user is logged in and the user can view sensitive shop data * */ $user_can_view = is_user_logged_in() && $customer_id == get_current_user_id() || ($customer_id == 0 || $customer_id == '-1') && !is_user_logged_in() && edd_get_purchase_session() || current_user_can('view_shop_sensitive_data'); if (!apply_filters('edd_user_can_view_receipt', $user_can_view, $edd_receipt_args)) { return $edd_receipt_args['error']; } ob_start(); edd_get_template_part('shortcode', 'receipt'); $display = ob_get_clean(); return $display; }
/** * Looks up purchases by email that match the registering user * * This is for users that purchased as a guest and then came * back and created an account. * * @access public * @since 1.6 * @param $user_id INT - the new user's ID * @return void */ function edd_add_past_purchases_to_new_user($user_id) { $email = get_the_author_meta('user_email', $user_id); $payments = edd_get_payments(array('s' => $email)); if ($payments) { foreach ($payments as $payment) { if (intval(edd_get_payment_user_id($payment->ID)) > 0) { continue; } // This payment already associated with an account $meta = edd_get_payment_meta($payment->ID); $meta['user_info'] = maybe_unserialize($meta['user_info']); $meta['user_info']['id'] = $user_id; $meta['user_info'] = $meta['user_info']; // Store the updated user ID in the payment meta edd_update_payment_meta($payment->ID, '_edd_payment_meta', $meta); edd_update_payment_meta($payment->ID, '_edd_payment_user_id', $user_id); } } }
/** * Process refunds * * @access public * @since 1.0.0 * @param int $payment_id The ID of a payment * @param string $new_status The new status of the payment * @param string $old_status The old status of the payment * @return void */ public function process_refund($payment_id, $new_status, $old_status) { if ($old_status != 'publish' && $old_status != 'revoked') { return; } if ($new_status != 'refunded') { return; } if (edd_get_payment_gateway($payment_id) !== 'wallet') { return; } $user_id = edd_get_payment_user_id($payment_id); $refund_amount = edd_get_payment_amount($payment_id); // Deposit the funds edd_wallet()->wallet->deposit($user_id, $refund_amount, 'refund'); // Insert payment note edd_insert_payment_note($payment_id, __('Refund completed to Wallet.', 'edd-wallet')); }
/** * Add the deposited amount to the wallet after payment * * @since 1.0.0 * @param int $payment_id The ID of the payment * @return void */ function edd_wallet_add_funds($payment_id) { $fees = edd_get_payment_fees($payment_id); if ($fees && count($fees) == 1) { if ($fees[0]['id'] == 'edd-wallet-deposit') { // Disable purchase receipts... we send our own emails remove_action('edd_complete_purchase', 'edd_trigger_purchase_receipt', 999); // Send our custom emails edd_wallet_send_email('user', $payment_id); // Get the ID of the purchaser $user_id = edd_get_payment_user_id($payment_id); // Deposit the funds edd_wallet()->wallet->deposit($user_id, $fees[0]['amount'], 'deposit', $payment_id); // Tag the payment so we can find it later edd_update_payment_meta($payment_id, '_edd_wallet_deposit', $user_id); } } }
/** * Is the payment provided associated with a user account * * @since 2.4.4 * @param int $payment_id The payment ID * @return bool If the payment is associted with a user (false) or not (true) */ function edd_is_guest_payment($payment_id) { $payment_user_id = edd_get_payment_user_id($payment_id); $is_guest_payment = !empty($payment_user_id) && $payment_user_id > 0 ? false : true; return (bool) apply_filters('edd_is_guest_payment', $is_guest_payment, $payment_id); }
/** * Looks up purchases by email that match the registering user * * This is for users that purchased as a guest and then came * back and created an account. * * @access public * @since 1.6 * @param $user_id INT - the new user's ID * @return void */ function edd_add_past_purchases_to_new_user($user_id) { $email = get_user_meta($user_id, 'user_email', true); $mode = edd_is_test_mode() ? 'test' : 'live'; $payments = edd_get_payments(array('s' => $email, 'mode' => $mode)); if ($payments) { foreach ($payments as $payment) { if (intval(edd_get_payment_user_id($payment->ID)) > 0) { continue; } // This payment already associated with an account $meta = edd_get_payment_meta($payment->ID); $meta['user_info'] = maybe_unserialize($meta['user_info']); $meta['user_info']['id'] = $user_id; $meta['user_info'] = serialize($meta['user_info']); // Store the updated user ID in the payment meta update_post_meta($payment->ID, '_edd_payment_meta', $meta); } } }
/** * Find old pending carts and consider them abandoned. * @return null */ public static function find_old_abandoned_carts() { $time = time(); $thirty_mins_ago = $time - apply_filters('find_old_abandoned_carts_mins_ago', 1800); // a half hour $args = array('status' => array('abandoned', 'pending'), 'start_date' => $thirty_mins_ago, 'end_date' => $time); $pending_payments = new EDD_Payments_Query($args); $payments = $pending_payments->get_payments(); if (empty($payments)) { return; } foreach ($payments as $payment) { $payment_id = $payment->ID; $user_id = edd_get_payment_user_id($payment_id); $uid = EDD_Segment_Identity::get_uid_from_user_id($user_id); $meta = edd_get_payment_meta($payment_id); // Adding an event for each item foreach ($meta['cart_details'] as $key => $item_details) { $item_details = array_merge($item_details, array('time' => time())); do_action('edd_segment_track', $uid, 'Abandoned Cart', $item_details); } } }
function edd_downloads_receipt_shortcode($atts, $content = null) { global $edd_receipt_args; $edd_receipt_args = shortcode_atts(array('error' => __('Sorry, trouble retrieving payment receipt.', 'edd_downloads'), 'price' => true, 'discount' => true, 'products' => true, 'date' => true, 'notes' => true, 'payment_key' => false, 'payment_method' => true, 'payment_id' => true), $atts, 'edd_receipt'); $session = edd_get_purchase_session(); if (isset($session['downloads']) && is_array($session['downloads'])) { foreach ($session['downloads'] as $download) { if (isset($download['upgrade']) && $download['upgrade']['upgrade_license'] > 0) { $payment_id_lic = get_post_meta(absint($download['upgrade']['upgrade_license']), '_edd_sl_payment_id', true); $payment_key = edd_get_payment_key($payment_id_lic); break; } } } if (!isset($payment_key)) { if (isset($_GET['payment_key'])) { $payment_key = urldecode($_GET['payment_key']); } elseif ($edd_receipt_args['payment_key']) { $payment_key = $edd_receipt_args['payment_key']; } else { if ($session) { $payment_key = $session['purchase_key']; } } } // No key found if (!isset($payment_key)) { return $edd_receipt_args['error']; } $edd_receipt_args['id'] = edd_get_purchase_id_by_key($payment_key); $customer_id = edd_get_payment_user_id($edd_receipt_args['id']); /* * Check if the user has permission to view the receipt * * If user is logged in, user ID is compared to user ID of ID stored in payment meta * * Or if user is logged out and purchase was made as a guest, the purchase session is checked for * * Or if user is logged in and the user can view sensitive shop data * */ $user_can_view = is_user_logged_in() && $customer_id == get_current_user_id() || ($customer_id == 0 || $customer_id == '-1') && !is_user_logged_in() && edd_get_purchase_session() || current_user_can('view_shop_sensitive_data'); if (!apply_filters('edd_user_can_view_receipt', $user_can_view, $edd_receipt_args)) { return $edd_receipt_args['error']; } require plugin_dir_path(__FILE__) . "template/shortcode-receipt.php"; }
public function cryptocoin_payment($payment) { global $gourl; if (!is_object($payment) || edd_get_payment_gateway($payment->ID) != "gourl") { return true; } // Current Order Details $status = $payment->post_status; $amount = edd_get_payment_amount($payment->ID); $currency = edd_get_payment_currency_code($payment->ID); $userID = edd_get_payment_user_id($payment->ID); $orderID = "order" . $payment->ID; // file shortcode-receipt.php // filter 'edd_payment_receipt_before' inside <table> echo '</thead></table>'; if (!$payment || !$payment->ID) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div class='edd-alert edd-alert-error'>" . __('The GoUrl payment plugin was called to process a payment but could not retrieve the order details. Cannot continue!', GOURLEDD) . "</div>"; } elseif (!in_array($status, array("pending", "publish"))) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div class='edd-alert edd-alert-error'>" . sprintf(__("This order's status is '%s' - it cannot be paid for. Please contact us if you need assistance.", GOURLEDD), $status) . "</div>"; } elseif (!class_exists('gourlclass') || !defined('GOURL') || !is_object($gourl)) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div class='edd-alert edd-alert-error'>" . sprintf(__("Please try a different payment method. Admin need to install and activate wordpress plugin <a href='%s'>GoUrl Bitcoin Gateway for Wordpress</a> to accept Bitcoin/Altcoin Payments online.", GOURLEDD), "https://gourl.io/bitcoin-wordpress-plugin.html") . "</div>"; } elseif (!$this->payments || !$this->defcoin || true === version_compare(EDD_VERSION, '2.4.2', '<') || true === version_compare(GOURL_VERSION, '1.3.4', '<') || array_key_exists($currency, $this->coin_names) && !array_key_exists($currency, $this->payments)) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div class='edd-alert edd-alert-error'>" . sprintf(__('Sorry, but there was an error processing your order. Please try a different payment method or contact us if you need assistance (GoUrl Bitcoin Plugin not configured / %s not activated).', GOURLEDD), !$this->payments || !$this->defcoin || !isset($this->coin_names[$currency]) ? $this->title : $this->coin_names[$currency]) . "</div>"; } else { $plugin = "gourledd"; $period = "NOEXPIRY"; $language = $this->deflang; $coin = $this->coin_names[$this->defcoin]; $affiliate_key = 'gourl'; $crypto = array_key_exists($currency, $this->coin_names); if (!$userID) { $userID = "guest"; } // allow guests to make checkout (payments) if (!$userID) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div align='center'><a href='" . wp_login_url(get_permalink()) . "'>\n\t\t\t\t\t\t\t<img style='border:none;box-shadow:none;' title='" . __('You need first to login or register on the website to make Bitcoin/Altcoin Payments', GOURLEDD) . "' vspace='10'\n\t\t\t\t\t\t\tsrc='" . $gourl->box_image() . "' border='0'></a></div>"; } elseif ($amount <= 0) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div class='edd-alert edd-alert-error'>" . sprintf(__("This order's amount is %s - it cannot be paid for. Please contact us if you need assistance.", GOURLEDD), $amount . " " . $currency) . "</div>"; } else { // Exchange (optional) // -------------------- if ($currency != "USD" && !$crypto) { $amount = gourl_convert_currency($currency, "USD", $amount); if ($amount <= 0) { echo '<h3>' . __('Information', GOURLEDD) . '</h3>' . PHP_EOL; echo "<div class='edd-alert edd-alert-error'>" . sprintf(__('Sorry, but there was an error processing your order. Please try later or use a different payment method. System cannot receive exchange rates for %s/USD from Google Finance', GOURLEDD), $currency) . "</div>"; } else { $currency = "USD"; } } if (!$crypto) { $amount = $amount * $this->emultiplier; } // Payment Box // ------------------ if ($amount > 0) { // crypto payment gateway $result = $gourl->cryptopayments($plugin, $amount, $currency, $orderID, $period, $language, $coin, $affiliate_key, $userID, $this->iconwidth); if (!isset($result["is_paid"]) || !$result["is_paid"]) { echo '<h3>' . __('Pay Now -', GOURLEDD) . '</h3>' . PHP_EOL; } if ($result["error"]) { echo "<div class='edd-alert edd-alert-error'>" . __("Sorry, but there was an error processing your order. Please try a different payment method.", GOURLEDD) . "<br/>" . $result["error"] . "</div>"; } else { // display payment box or successful payment result echo $result["html_payment_box"]; // payment received if ($result["is_paid"]) { if (false) { echo "<div align='center'>" . sprintf(__('%s Payment ID: #%s', GOURLEDD), ucfirst($result["coinname"]), $result["paymentID"]) . "</div>"; } echo "<br/>"; if ($status == 'pending') { header('Location: ' . $_SERVER['REQUEST_URI']); } } } } } } echo '<br/><br/><table id="edd_purchase_receipt"><thead>'; return true; }
<p class="description"><?php _e('If needed, you can update the buyer\'s email here.', 'edd'); ?> </p> </td> </tr> <tr> <th scope="row" valign="top"> <span><?php _e('Buyer\'s User ID', 'edd'); ?> </span> </th> <td> <input class="small-text" type="number" min="-1" step="1" name="edd-buyer-user-id" id="edd-buyer-user-id" value="<?php echo edd_get_payment_user_id($payment_id); ?> "/> <p class="description"><?php _e('If needed, you can update the buyer\'s WordPress user ID here.', 'edd'); ?> </p> </td> </tr> <tr> <th scope="row" valign="top"> <span><?php printf(__('Payment Amount in %s', 'edd'), edd_get_currency()); ?> </span> </th>
/** * Email the custom download link(s) and payment confirmation to the buyer in a * customizable Purchase Receipt * * @since 1.0 * @param int $payment_id Payment ID * @param bool $admin_notice Whether to send the admin email notification or not (default: true) * @return void */ function edd_ppe_email_custom_purchase_receipts($payment_id, $admin_notice = true) { $payment_data = edd_get_payment_meta($payment_id); $user_id = edd_get_payment_user_id($payment_id); $user_info = maybe_unserialize($payment_data['user_info']); $email = edd_get_payment_user_email($payment_id); if (isset($user_id) && $user_id > 0) { $user_data = get_userdata($user_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; } // get cart items from payment ID $cart_items = edd_get_payment_meta_cart_details($payment_id); // loop through each item in cart and add IDs to $product_id array foreach ($cart_items as $product) { $product_ids[] = $product['id']; } foreach ($product_ids as $product_id) { if (!edd_ppe_is_receipt_active(edd_ppe_get_receipt_id($product_id))) { continue; } $receipt = get_post(edd_ppe_get_receipt_id($product_id)); // default email body $default_email_body = __("Dear", "edd-ppe") . " {name},\n\n"; $default_email_body .= __("Thank you for purchasing {download_name}. Please click on the link(s) below to download your files.", "edd-ppe") . "\n\n"; $default_email_body .= "{download_list}\n\n"; $default_email_body .= "{sitename}"; // use new EDD 2.1 Email class if (class_exists('EDD_Emails')) { // get our subject $subject = apply_filters('edd_ppe_purchase_subject', $receipt->post_excerpt ? wp_strip_all_tags($receipt->post_excerpt, true) : __('Purchase Receipt - {download_name}', 'edd-ppe'), $payment_id); // run subject through the plugin's custom email tag function // this runs before so apostrophe's can correctly be replaced when {sitename} is used in the subject. This will eventually be fixed in EDD core $subject = edd_ppe_email_template_tags($subject, $product_id); // run subject through the standard EDD email tag function $subject = edd_do_email_tags($subject, $payment_id); // message $message = apply_filters('edd_ppe_purchase_body', $receipt->post_content ? $receipt->post_content : $default_email_body); // run our message through the standard EDD email tag function $message = apply_filters('edd_purchase_receipt', edd_do_email_tags($message, $payment_id), $payment_id, $payment_data); // run the message through the plugin's custom email tag function $message = edd_ppe_email_template_tags($message, $product_id); // add download name as email heading. Off by default // will introduce a checkbox in admin to turn all headings on rather than turn them on now which may mess up emails if (apply_filters('edd_ppe_email_heading', false)) { EDD()->emails->__set('heading', get_the_title($product_id)); } // send an email for each custom email EDD()->emails->send($email, $subject, $message); } else { // support older EDD versions where the EDD Email Class does not exist $subject = apply_filters('edd_ppe_purchase_subject', $receipt->post_excerpt ? wp_strip_all_tags($receipt->post_excerpt, true) : __('Purchase Receipt - {download_name}', 'edd-ppe'), $payment_id); $body = apply_filters('edd_ppe_purchase_body', $receipt->post_content ? $receipt->post_content : $default_email_body); $body = edd_ppe_email_template_tags($body, $product_id); $subject = edd_email_template_tags($subject, $payment_data, $payment_id); $subject = edd_ppe_email_template_tags($subject, $product_id); $message = edd_get_email_body_header(); $message .= apply_filters('edd_purchase_receipt', edd_email_template_tags($body, $payment_data, $payment_id), $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'); $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"; $headers = apply_filters('edd_receipt_headers', $headers, $payment_id, $payment_data); // Allow add-ons to add file attachments $attachments = apply_filters('edd_receipt_attachments', array(), $payment_id, $payment_data); wp_mail($email, $subject, $message, $headers, $attachments); } } }
/** * Render the User Column * * @access public * @since 1.4 * @param array $payment Contains all the data of the payment * @return string Data shown in the User column */ public function column_user($payment) { $user_id = edd_get_payment_user_id($payment->ID); if ($user_id && $user_id > 0) { $user = get_userdata($user_id); $display_name = is_object($user) ? $user->display_name : __('guest', 'edd'); } else { $display_name = __('guest', 'edd'); } $value = '<a href="' . esc_url(add_query_arg(array('user' => urlencode($payment->user_info['email']), 'paged' => false))) . '">' . $display_name . '</a>'; return apply_filters('edd_payments_table_column', $value, $payment->ID, 'user'); }
*/ if (!isset($_GET['id']) || !is_numeric($_GET['id'])) { wp_die(__('Payment ID not supplied. Please try again', 'edd'), __('Error', 'edd')); } // Setup the variables $payment_id = absint($_GET['id']); $number = edd_get_payment_number($payment_id); $item = get_post($payment_id); // Sanity check... fail if purchase ID is invalid if (!is_object($item) || $item->post_type != 'edd_payment') { wp_die(__('The specified ID does not belong to a payment. Please try again', 'edd'), __('Error', 'edd')); } $payment_meta = edd_get_payment_meta($payment_id); $transaction_id = esc_attr(edd_get_payment_transaction_id($payment_id)); $cart_items = edd_get_payment_meta_cart_details($payment_id); $user_id = edd_get_payment_user_id($payment_id); $customer_id = edd_get_payment_customer_id($payment_id); $payment_date = strtotime($item->post_date); $unlimited = edd_payment_has_unlimited_downloads($payment_id); $user_info = edd_get_payment_meta_user_info($payment_id); $address = !empty($user_info['address']) ? $user_info['address'] : array('line1' => '', 'line2' => '', 'city' => '', 'country' => '', 'state' => '', 'zip' => ''); $gateway = edd_get_payment_gateway($payment_id); $currency_code = edd_get_payment_currency_code($payment_id); ?> <div class="wrap edd-wrap"> <h2><?php printf(__('Payment %s', 'edd'), $number); ?> </h2> <?php do_action('edd_view_order_details_before', $payment_id);
/** * Looks up purchases by email that match the registering user * * This is for users that purchased as a guest and then came * back and created an account. * * @access public * @since 1.6 * @param $user_id INT - the new user's ID * @return void */ function edd_add_past_purchases_to_new_user($user_id) { $email = get_the_author_meta('user_email', $user_id); $payments = edd_get_payments(array('s' => $email)); if ($payments) { // Set a flag to force the account to be verified before purchase history can be accessed edd_set_user_to_pending($user_id); edd_send_user_verification_email($user_id); foreach ($payments as $payment) { if (intval(edd_get_payment_user_id($payment->ID)) > 0) { continue; // This payment already associated with an account } $meta = edd_get_payment_meta($payment->ID); $meta['user_info'] = maybe_unserialize($meta['user_info']); $meta['user_info']['id'] = $user_id; $meta['user_info'] = $meta['user_info']; // Store the updated user ID in the payment meta edd_update_payment_meta($payment->ID, '_edd_payment_meta', $meta); edd_update_payment_meta($payment->ID, '_edd_payment_user_id', $user_id); } } }