Enable Sales Alerts for Digital Downloads wihtout plugin

Selling digital downloads is something that not a single one of the large WordPress ecommerce plugins has ever gotten really right. This plugin aims to fix that. Instead of focusing on providing every single feature under the sun, Easy Digital Downloads tries to provide only the ones that you really need. It aims to make selling digital downloads through WordPress easy, and complete.

Enable Sales Alerts for Digital Downloads wihtout plugin. You will first need to add the ID of the download you wish to be alerted about. You can then set the default milestone amount, currently the snippet is at 100.

You can download his full code base from following URL

https://github.com/easydigitaldownloads/Easy-Digital-Downloads

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’ );

 

Credit goes to Andrew Munro. Thanks him for this snippet.