Order Total and Buyer in EDD Sale Notification Subjects
Changes the subject of the "New sale" email you receive to include the amount and the buyer's name, so you can see each sale from your inbox.
Opens WPIDE on
Code
add_filter( 'edd_admin_sale_notification_subject', function ( $subject, $order_id ) {
$order = function_exists( 'edd_get_order' ) ? edd_get_order( $order_id ) : false;
if ( ! $order ) {
return $subject;
}
$customer = edd_get_customer( $order->customer_id );
$name = $customer && $customer->name ? $customer->name : $order->email;
return sprintf( 'New sale: %1$s from %2$s (#%3$s)', html_entity_decode( edd_currency_filter( edd_format_amount( $order->total ), $order->currency ) ), $name, $order->get_number() );
}, 10, 2 );
Notes
Change the wording in the sprintf line; only the admin sale notification is affected.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.