Skip to main content
Easy Digital Downloads Documentation
Documentation, Reference Materials, and Tutorials for Easy Digital Downloads

Managing Easy Digital Downloads Email Tags

Easy Digital Downloads uses template tags to allow you to insert data into your emails.  These are simply functions that output data for rendering in the email.  These are the default template tags:

  • {phone} – Customer’s phone number
  • {download_list} – A list of downloads with clickable links for each download purchased
    Note: The Sale Notification email will not include clickable links, as those are only intended for the customer’s email receipt.
  • {file_urls} – A plain-text list of download URLs for each download purchased
  • {name} – The buyer’s first name
  • {fullname} – The buyer’s full name, first and last
  • {username} – The buyer’s user name on the site, if they registered an account
  • {user_email} – The buyer’s email address
  • {billing_address} – The buyer’s billing address
  • {date} – The date of the purchase
  • {subtotal} – The price of the purchase before taxes
  • {tax} – The taxed amount of the purchase
  • {price} – The total price of the purchase
  • {payment_id} – The unique ID number for this purchase
  • {receipt_id} – The unique ID number for this purchase receipt
  • {payment_method} – The method of payment used for this purchase
  • {sitename} – Your site name
  • {receipt_link} – Adds a link so users can view their receipt directly on your website if they are unable to view it in the browser correctly.
  • {discount_codes} – Adds a list of any discount codes applied to this purchase
  • {ip_address} – The buyer’s IP Address

EDD has built in functions to help you create new tags, remove existing tags, and test to see a given tag exists.

Adding a New Tag

The first thing you should make is the function that will render the information you wish.  Below is a very simple example that outputs the site title:

function edd_show_site_title() {
	return get_the_title();
}

As with any function be sure to prefix it with something unique. It could be edd_ or anything else unique.

Next we’ll make a function to hook the above function properly.

function edd_my_add_tags() {
	edd_add_email_tag( 'site_title', 'Adds the site title', 'edd_show_site_title' );
}

Lastly we’ll hook that to the proper place in Easy Digital Downloads.

add_action( 'edd_add_email_tags', 'edd_my_add_tags' );

So then the whole thing looks like this:

function edd_show_site_title() {
	return get_the_title();
}
function edd_my_add_tags() {
	edd_add_email_tag( 'site_title', 'Adds the site title', 'edd_show_site_title' );
}
add_action( 'edd_add_email_tags', 'edd_my_add_tags' );

The output on the Email Settings page would look something like this:

Removing a Tag

If you’re removing a tag you created, simply remove all the code you wrote to make it.  Once the transient expires then it’ll be gone.  If you want to remove a core tag, you can use something like the example below:

function edd_my_remove_tags() {
    edd_remove_email_tag( 'phone' );
}   
add_action( 'edd_add_email_tags', 'edd_my_remove_tags', 99 );

In the example above, ‘phone’ is the name of the tag.  We still hook into edd_add_email_tags even though we’re removing. Note the priority of 99. WordPress default action-hook priority is 10. By over-riding that and setting it to 99, we are telling it to run after any other hooked function with a priority less than 99. If the email tag you are trying to remove happens to gets added in a function with a priority higher than 99, you’ll have to increase the priority to make sure it is greater than that number – and thus runs “after” the tag is added. Essentially, you can’t remove a tag that has not been added yet.

Looking for a Tag

If you want to see if a tag exists then you can do something like this:

if ( edd_email_tag_exists( 'name' ) ) {
	echo "Yep!";
}

edd_email_tag_exists() returns boolean.

Read our latest blog post:
Add More Stripe Payment Methods at Checkout