Created
November 26, 2014 19:54
-
-
Save amdrew/ddfb18ec1e3db858cfe8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| /* | |
| Plugin Name: Easy Digital Downloads - Downloads Email Tag | |
| Plugin URI: http://sumobi.com/ | |
| Description: Adds a {downloads} email tag for use in email templates that outputs a simple list of linked downloads without file names | |
| Version: 1.0 | |
| Author: Andrew Munro, Sumobi | |
| Author URI: http://sumobi.com/ | |
| License: GPL-2.0+ | |
| License URI: http://www.opensource.org/licenses/gpl-license.php | |
| */ | |
| /** | |
| * Add a {downloads} tag for use in either the purchase receipt email or admin notification emails | |
| */ | |
| edd_add_email_tag( 'downloads', __( 'A linked list of downloads purchased', 'edd_det_email_tag_downloads' ), 'edd_det_email_tag_downloads' ); | |
| /** | |
| * The {downloads} email tag | |
| * @todo check for existance of EDD first! | |
| */ | |
| function edd_det_email_tag_downloads( $payment_id ) { | |
| $cart_items = edd_get_payment_meta_cart_details( $payment_id ); | |
| $download_list = '<ul>'; | |
| if ( $cart_items ) { | |
| 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 ); | |
| $title = apply_filters( 'edd_det_link_title', sprintf( '<a href="%s">%s</a>', get_permalink( $item['id'] ), get_the_title( $item['id'] ) ), $item['id'] ); | |
| // add sku to title | |
| if ( ! empty( $sku ) ) { | |
| $title .= " – " . __( 'SKU', 'edd' ) . ': ' . $sku; | |
| } | |
| // add variable pricing option to title | |
| if ( $price_id ) { | |
| $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 .= '</li>'; | |
| } | |
| } | |
| $download_list .= '</ul>'; | |
| return apply_filters( 'edd_det_email_tag_html', $download_list, $title, $item, $price_id, $payment_id ); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment