How to Change the Payment Delimiter Inside Email Notifications

Overview

Would you like to change the payment delimiter in email notifications? By default, all payment amounts inside the email notifications are separated with a hyphen (-) but you can easily change this with a small PHP snippet and we’ll show you how!

Setup

First, you’ll need to copy the snippet to your site.

If you need any help in know where or how to add snippets to your site, please review this tutorial.

/*
 * Change payment delimiter in the email notification.
 *
 * @link https://wpforms.com/developers/how-to-change-the-payment-delimiter-inside-email-notifications/
*/

function wpf_dev_entry_email_data( $fields, $entry, $form_data ) {
    
	// Only run on my form with ID = 890
	if ( absint( $form_data[ 'id' ] ) !== 890 ) {
	return;
	}

	
    foreach ( $fields as &$field ) {

		if ( empty( $field[ 'value_choice' ] ) ) {
			continue;
		}
		
		// Default is a dash -, change here to what you need.
		$delimiter = ' : ';

		$field[ 'value' ] = $field[ 'value_choice' ] . $delimiter . wpforms_format_amount( $field[ 'amount_raw' ], true );
	}
	
	return $fields;
	
}
add_filter( 'wpforms_entry_email_data' , 'wpf_dev_entry_email_data', 10, 3  );

This code snippet will change the Dropdown, Checkbox and Multiple Choice payment form fields for the form 890 from using the default hyphen to a colon (:).

You’ll need to update the form ID in the snippet to match your form ID. If you’re not sure how to find your form ID, please check out this tutorial.

By adding this code snippet you can change the payment delimiter in email notifications from a dash to a colon

And that’s it! You’ve successfully changed the delimiter. Would you like to also like to send metadata to Stripe when the payment is processed? Take a look at our tutorial on How To Send Metadata to Stripe Payments.

Filter Reference: wpforms_entry_email_data