Skip to content

Instantly share code, notes, and snippets.

@amdrew
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save amdrew/9178690 to your computer and use it in GitHub Desktop.
Save amdrew/9178690 to your computer and use it in GitHub Desktop.
Easy Digital Downloads - add a new email tag called {vendor_emails}. This will output each download and the email address of who added it.
<?php
/**
* Example
* For more information about your order, please contact one of the following vendors:
* {vendor_emails}
* /
/**
* Add a {vendor_emails} tag
*/
function sumobi_edd_email_tags( $email_tags ) {
$email_tags[] = array(
'tag' => 'vendor_emails',
'description' => 'List each download purchased with the email address of the Shop vendor who added it',
'function' => 'sumobi_edd_vendor_emails'
);
return $email_tags;
}
add_filter( 'edd_email_tags', 'sumobi_edd_email_tags' );
/**
* List each download with the email of the author (Shop Vendor who added it)
*/
function sumobi_edd_vendor_emails() {
ob_start();
$downloads = edd_get_purchase_session();
$downloads = $downloads['downloads'];
if ( $downloads ) {
foreach ( $downloads as $key => $download ) {
$post = get_post( $download['id'] );
$author_id = $post->post_author;
// download title
echo get_the_title( $download['id'] ) . '<br/>';
// the email address of the author who added the download
echo get_the_author_meta( 'user_email', $author_id ) . '<br/><br/>';
}
}
$html = ob_get_clean();
return $html;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment