Home / admin / Milestone Sales Alert with Easy Digital Downloads
  • How to Milestone Sales Alert with Easy Digital Downloads


    This is a simple but great snippet for Easy Digital Downloads that will email the admin when a specific download milestone has been reached. You will need to change the $download_id, to the ID of the download and then change the $milestone to the sales milestone you want to the email.

    ( click code to copy )

    wordpress snippet : PHP

    function sumobi_edd_milestone_sales_alert( $purchase_id ) {
       $download_id = 8; // ID of download to check
       $milestone = 100; // sales milestone to reach
       $send_to = get_option( 'admin_email' );
       $sales = get_post_meta( $download_id, '_edd_download_sales', true );
       $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 ) );
        if ( $milestone == $sales ) {
            wp_mail( $send_to, 'Milestone reached!', $message );
    add_action( 'edd_complete_purchase', 'sumobi_edd_milestone_sales_alert' );

    ( WordPress codex functions, hooks, in this snippet. )

    admin_email, the_title, get_post, get_post_meta, get_the_title, add_action, get_option, _e, admin_url, wp, wp_mail,