<?php if (edd_is_payment_complete($payment->ID) && edd_receipt_show_download_files($item['id'], $edd_receipt_args, $item)) { ?> <ul class="edd_purchase_receipt_files"> <?php if (!empty($download_files) && is_array($download_files)) { foreach ($download_files as $filekey => $file) { $download_url = edd_get_download_file_url($meta['key'], $email, $filekey, $item['id'], $price_id); ?> <li class="edd_download_file"> <a href="<?php echo esc_url($download_url); ?> " class="edd_download_file_link"><?php echo edd_get_file_name($file); ?> </a> </li> <?php do_action('edd_receipt_files', $filekey, $file, $item['id'], $payment->ID, $meta); } } elseif (edd_is_bundled_product($item['id'])) { $bundled_products = edd_get_bundled_products($item['id']); foreach ($bundled_products as $bundle_item) { ?> <li class="edd_bundled_product"> <span class="edd_bundled_product_name"><?php echo get_the_title($bundle_item); ?> </span>
/** * Gets the download links for each item purchased * * @since 1.1.5 * @param int $payment_id The ID of the payment to retrieve download links for * @return string */ function edd_get_purchase_download_links($payment_id = 0) { $downloads = edd_get_payment_meta_cart_details($payment_id, true); $payment_key = edd_get_payment_key($payment_id); $email = edd_get_payment_user_email($payment_id); $links = '<ul class="edd_download_links">'; foreach ($downloads as $download) { $links .= '<li>'; $links .= '<h3 class="edd_download_link_title">' . esc_html(get_the_title($download['id'])) . '</h3>'; $price_id = isset($download['options']) && isset($download['options']['price_id']) ? $download['options']['price_id'] : null; $files = edd_get_download_files($download['id'], $price_id); if (is_array($files)) { foreach ($files as $filekey => $file) { $links .= '<div class="edd_download_link_file">'; $links .= '<a href="' . esc_url(edd_get_download_file_url($payment_key, $email, $filekey, $download['id'], $price_id)) . '">'; $links .= edd_get_file_name($file); $links .= '</a>'; $links .= '</div>'; } } $links .= '</li>'; } $links .= '</ul>'; return $links; }
/** * Email template tag: updated_products_links * A list of updated products with download links included * * @access public * @param mixed $payment_id * @return void */ function edd_pup_products_links_tag_plain($payment_id, $email = null) { // Used to generate accurate tag outputs for preview and test emails if (isset($email) && absint($email) != 0) { $updated_products = get_post_meta($email, '_edd_pup_updated_products', true); $updated_products = is_array($updated_products) ? $updated_products : array($updated_products); foreach ($updated_products as $id => $name) { $customer_updates[$id] = array('id' => $id, 'name' => $name); } } else { $email = get_transient('edd_pup_sending_email_' . get_current_user_id()); $updated_products = get_post_meta($email, '_edd_pup_updated_products', true); $updated_products = is_array($updated_products) ? $updated_products : array($updated_products); $customer_updates = edd_pup_get_customer_updates($payment_id, $email); $customer_updates = is_array($customer_updates) ? $customer_updates : array($customer_updates); } $filters = get_post_meta($email, '_edd_pup_filters', true); if ($customer_updates) { $show_names = apply_filters('edd_pup_email_show_names', true); $payment_data = edd_get_payment_meta($payment_id); // Set email to most recent email if it's been changed from initial email if (isset($payment_data['user_info']['email']) && $payment_data['user_info']['email'] != $payment_data['email']) { $payment_data['email'] = $payment_data['user_info']['email']; } // Used for detecting when to place commas $c = 1; $download_list = ''; foreach ($customer_updates as $item) { if (edd_use_skus()) { $sku = edd_get_download_sku($item['id']); } $price_id = edd_get_cart_item_price_id($item); if ($show_names) { $title = $c == 1 ? $item['name'] : ', ' . $item['name']; if (!empty($sku)) { $title .= " – " . __('SKU', 'edd') . ': ' . $sku; } $download_list .= apply_filters('edd_pup_email_products_link_title_plain', $title, $item, $price_id, $payment_id); } $files = edd_get_download_files($item['id'], $price_id); if ($files) { // $f used for detecting when to place commas $f = 1; $download_list .= ' ('; foreach ($files as $filekey => &$file) { $file_url = edd_get_download_file_url($payment_data['key'], $payment_data['email'], $filekey, $item['id'], $price_id); $download_list .= $f == 1 ? edd_get_file_name($file) . ': ' . esc_url($file_url) : ', ' . edd_get_file_name($file) . ': ' . esc_url($file_url); $f++; } $download_list .= ')'; } if (edd_is_bundled_product($item['id'])) { $b = 1; $bundled_products = edd_get_bundled_products($item['id']); $download_list .= " – "; foreach ($bundled_products as $bundle_item) { if ($filters['bundle_1'] == 'all' || isset($updated_products[$bundle_item])) { $download_list .= $b == 1 ? get_the_title($bundle_item) : '; ' . get_the_title($bundle_item); $fb = 1; $bundlefiles = edd_get_download_files($bundle_item); $download_list .= ' ('; foreach ($bundlefiles as $bundlefilekey => $bundlefile) { $bundlefile_url = edd_get_download_file_url($payment_data['key'], $payment_data['email'], $bundlefilekey, $bundle_item, $price_id); $download_list .= $fb == 1 ? $bundlefile['name'] . ': ' . esc_url($bundlefile_url) : ', ' . $bundlefile['name'] . ': ' . esc_url($bundlefile_url); $fb++; } $download_list .= ')'; } $b++; } } if ('' != edd_get_product_notes($item['id'])) { $download_list .= ' – ' . edd_get_product_notes($item['id']); } $c++; } return $download_list; } }
/** * Email template tag: download_list * A list of download links for each download purchased in plaintext * * @since 2.1.1 * @param int $payment_id * * @return string download_list */ function edd_email_tag_download_list_plain($payment_id) { $payment_data = edd_get_payment_meta($payment_id); $cart_items = edd_get_payment_meta_cart_details($payment_id); $email = edd_get_payment_user_email($payment_id); $download_list = ''; if ($cart_items) { $show_names = apply_filters('edd_email_show_names', true); $show_links = apply_filters('edd_email_show_links', true); foreach ($cart_items as $item) { if (edd_use_skus()) { $sku = edd_get_download_sku($item['id']); } if (edd_item_quantities_enabled()) { $quantity = $item['quantity']; } $price_id = edd_get_cart_item_price_id($item); if ($show_names) { $title = get_the_title($item['id']); if (!empty($quantity) && $quantity > 1) { $title .= __('Quantity', 'easy-digital-downloads') . ': ' . $quantity; } if (!empty($sku)) { $title .= __('SKU', 'easy-digital-downloads') . ': ' . $sku; } if ($price_id !== null) { $title .= edd_get_price_option_name($item['id'], $price_id, $payment_id); } $download_list .= "\n"; $download_list .= apply_filters('edd_email_receipt_download_title', $title, $item, $price_id, $payment_id) . "\n"; } $files = edd_get_download_files($item['id'], $price_id); if (!empty($files)) { foreach ($files as $filekey => $file) { if ($show_links) { $download_list .= "\n"; $file_url = edd_get_download_file_url($payment_data['key'], $email, $filekey, $item['id'], $price_id); $download_list .= edd_get_file_name($file) . ': ' . $file_url . "\n"; } else { $download_list .= "\n"; $download_list .= edd_get_file_name($file) . "\n"; } } } elseif (edd_is_bundled_product($item['id'])) { $bundled_products = apply_filters('edd_email_tag_bundled_products', edd_get_bundled_products($item['id']), $item, $payment_id, 'download_list'); foreach ($bundled_products as $bundle_item) { $download_list .= '<div class="edd_bundled_product"><strong>' . get_the_title($bundle_item) . '</strong></div>'; $files = edd_get_download_files($bundle_item); foreach ($files as $filekey => $file) { if ($show_links) { $file_url = edd_get_download_file_url($payment_data['key'], $email, $filekey, $bundle_item, $price_id); $download_list .= $file['name'] . ': ' . $file_url . "\n"; } else { $download_list .= $file['name'] . "\n"; } } } } if ('' != edd_get_product_notes($item['id'])) { $download_list .= "\n"; $download_list .= edd_get_product_notes($item['id']) . "\n"; } } } return $download_list; }
/** * Email template tag: download_list * A list of download links for each download purchased * * @param int $payment_id * * @return string download_list */ function edd_email_tag_download_list($payment_id) { $payment_data = edd_get_payment_meta($payment_id); $download_list = '<ul>'; $cart_items = edd_get_payment_meta_cart_details($payment_id); $email = edd_get_payment_user_email($payment_id); if ($cart_items) { $show_names = apply_filters('edd_email_show_names', true); foreach ($cart_items as $item) { if (edd_use_skus()) { $sku = edd_get_download_sku($item['id']); } $price_id = edd_get_cart_item_price_id($item); if ($show_names) { $title = get_the_title($item['id']); if (!empty($sku)) { $title .= " – " . __('SKU', 'edd') . ': ' . $sku; } if ($price_id !== false) { $title .= " – " . edd_get_price_option_name($item['id'], $price_id); } $download_list .= '<li>' . apply_filters('edd_email_receipt_download_title', $title, $item, $price_id, $payment_id) . '<br/>'; $download_list .= '<ul>'; } $files = edd_get_download_files($item['id'], $price_id); if ($files) { foreach ($files as $filekey => $file) { $download_list .= '<li>'; $file_url = edd_get_download_file_url($payment_data['key'], $email, $filekey, $item['id'], $price_id); $download_list .= '<a href="' . esc_url($file_url) . '">' . edd_get_file_name($file) . '</a>'; $download_list .= '</li>'; } } elseif (edd_is_bundled_product($item['id'])) { $bundled_products = edd_get_bundled_products($item['id']); foreach ($bundled_products as $bundle_item) { $download_list .= '<li class="edd_bundled_product"><strong>' . get_the_title($bundle_item) . '</strong></li>'; $files = edd_get_download_files($bundle_item); foreach ($files as $filekey => $file) { $download_list .= '<li>'; $file_url = edd_get_download_file_url($payment_data['key'], $email, $filekey, $bundle_item, $price_id); $download_list .= '<a href="' . esc_url($file_url) . '">' . $file['name'] . '</a>'; $download_list .= '</li>'; } } } if ($show_names) { $download_list .= '</ul>'; } if ('' != edd_get_product_notes($item['id'])) { $download_list .= ' — <small>' . edd_get_product_notes($item['id']) . '</small>'; } if ($show_names) { $download_list .= '</li>'; } } } $download_list .= '</ul>'; return $download_list; }