How To Enable Milestone Sales Alerts for Easy Digital Downloads

Snippets by IsItWP

Are you looking for a way to enable milestone sales alerts for Easy Digital Downloads? While there’s probably a plugin for this, we have created a quick code snippet that you can use to enable milestone sales alerts for Easy Digital Downloads in WordPress.


Add this code to your theme’s functions.php file or in a site-specific plugin.

function sumobi_edd_milestone_sales_alert( $purchase_id ) {
   // ID of download to check
   $download_id = 8;

   // sales milestone to reach
   $milestone = 100;

   // email/s to send the notification to. Add more emails to array if necessary
   $send_to = get_option( 'admin_email' );

   // get the current number of sales for the download
   $sales = get_post_meta( $download_id, '_edd_download_sales', true );

   // message to be included in the email
   $message = sprintf( 'Congratulations, you have just reached your milestone of %s sales for %s! View this sale here: %s', $milestone, get_the_title( $download_id ), admin_url( 'edit.php?post_type=download&page=edd-payment-history&view=view-order-details&id=' . $purchase_id ) );

   // send email is milestone is reached
   if ( $milestone == $sales ) {
      wp_mail( $send_to, 'Milestone reached!', $message );
add_action( 'edd_complete_purchase', 'sumobi_edd_milestone_sales_alert' );

You will need to change the $download_id in line 3 to the ID of the download and then change the $milestone variable in line 6 to the sales milestone you want to use. You can also set the notification email in line 9 to an array of emails or leave it as is.

This code was created by Andrew Munro.

Note: If this is your first time adding code snippets in WordPress, then please refer to our guide on how to properly copy / paste code snippets in WordPress, so you don’t accidentally break your site.

If you liked this code snippet, please consider checking out our other articles on the site like: 7 best download manager plugins and how to Create an Online Store.

Comments   Leave a Reply

Add a Comment

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.

WordPress Launch Checklist

The Ultimate WordPress Launch Checklist

We've compiled all the essential checklist items for your next WordPress website launch into one handy ebook.
Yes, Send Me the Free eBook!