How to Hide the Item Price Value in the Email Notifications

Overview

Would you like to hide the Item Price from the email notifications? You may need to hide either the total or just the item price or even another field from your email notifications. Using a small PHP snippet you can easily exclude the price from the notification.

Setup

Simply copy this code snippet to your site.

/*
 * Hide the price from notifications
 *
 * @link https://wpforms.com/developers/how-to-hide-the-item-price-value-in-the-email-notifications
 *
 */

function wpf_email_field_value( $value, $field, $form_data, $context) {
    
    if ( 'email-html' === $context ) {
		
        if ( 364 == $form_data['id'] && 19 == $field['id'] ) {
            return $field['value'];
        }
    }

    return $value;
}
add_filter( 'wpforms_html_field_value', 'wpf_email_field_value', 15, 4 );

You’ll need to update the code above so that it matches the correct form ID (364) and the correct field id (19). If you need assistance with finding these ID numbers, please review this documentation.

Now when the email notification is received, the label will still be there but the value will show empty.

How the price is hidden from the email notification

FAQ

Q: Can you use this to hide a Hidden Field from the email notification?

A: Absolutely! You would just change the 19 == $field['id'] to match the ID of the Hidden Field.