Search

How to Customize Email Templates in Product Enquiry Pro

    Sumit Pore
Listen to this article

Email NotificationsBased on my survey of WooCommerce inquiry plugins available, I bet the primary reason Product Enquiry Pro is the most popular – is because it’s easily customizable. (You already know this since you own the plugin. 🙂 )

It’s true. And we make sure of it with every update.

With the Product Enquiry for WooCommerce (free) plugin, we had a lot of users asking us for an option to customize the interface of the plugin. So when we rolled out the pro plugin, we made sure it provided simple settings to easily update the look of the enquiry button and dialog.

And with every version we released hence, we ensured that we added more and more customization options. However! As good plugin developers, we knew an overload of plugin settings could hamper user experience :D.

So, the next best thing – was to add filters and action hooks.

And we did!

Hooks can be used by plugin owners like you to easily customize the plugin using a bit of code. We know code can be a bit scary for some of you, so we’ve made sure we provide detailed documentation. And, we’ll keep on rolling out posts like these as well, to help you along the way.

In this post, we’ll be taking a look at customizing Product Enquiry Pro for WooCommerce plugin emails using simple filter hooks.

Let’s take a look.

[space]

Customizing Product Enquiry Pro Emails

The Product Enquiry Pro for WooCommerce sends two emails – the inquiry email to the admin, and to the customer (if ‘Send me a copy’ option is checked). For quite some time after the plugin’s release, the content of the emails was dictated by the plugin. As the plugin owner, you couldn’t change the contents of these emails.

Consequently, we had a few of you ask us if you could change the subject or add certain content into the email body, to help categorize enquiry emails sent. With the filters listed below, you can change the subject and content of the customer and admin emails.

[space]

#1 How to Customize PEP Admin Email

There are 8 filters provided which can be used to change the content of the admin email sent:

Filter Arguments Description
pep_before_customer_name_in_admin_email $enquiry_email, $form_data_for_mail Can be used to add content in a row above the Customer Name
pep_before_customer_email_in_admin_email $enquiry_email, $form_data_for_mail Can be used to add content in a row above the Customer Email
pep_before_customer_telephone_in_admin_email $enquiry_email, $form_data_for_mail Can be used to add content in a row above the Customer Telephone
pep_before_customer_message_in_admin_email $enquiry_email, $form_data_for_mail Can be used to add content in a row above the Customer Message
pep_before_product_name_in_admin_email $enquiry_email, $form_data_for_mail Can be used to add content in a row above the Product Name
pep_before_price_in_admin_email $enquiry_email, $form_data_for_mail Can be used to add content in a row above the product Price
pep_after_price_in_admin_email $enquiry_email, $form_data_for_mail Can be used to add content in a row below the product Price
pep_admin_email_content $enquiry_email Can be used to change the entire content of the email
pep_admin_email_subject $admin_subject Can be used to change the email subject

As an example, let’s suppose you want to add the time when the inquiry was made above the Customer Name in the email. You can do this using the ‘pep_before_customer_name_in_admin_email’ filter as follows:

add_filter( 'pep_before_customer_name_in_admin_email', 'add_date_time_before_customer_name', 10, 1 );
function add_date_time_before_customer_name($enquiry_email)
{
    $date_time_content =
    "<tr>
       <th style='width:25%;text-align:left'>" . __( 'Time', 'pep_text_domain' ) . " </th>
       <td style='width:75%'>:" . date('l jS \of F Y h:i:s A') .  "</td>
     </tr>";
    return $date_time_content.$enquiry_email;
}

[space]

#2 How to Customize PEP Customer Email

Similar to admin email filters, Product Enquiry Pro provides filters for the customer email as well:

Filter Arguments Description
pep_before_product_name_in_customer_email $cust_email, $form_data_for_mail Can be used to add content in a row above the Product Name
pep_before_price_in_customer_email $cust_email, $form_data_for_mail Can be used to add content in a row above the product Price
pep_before_message_in_customer_email $cust_email, $form_data_for_mail Can be used to add content in a row above the Message
pep_after_message_in_customer_email $cust_email, $form_data_for_mail Can be used to add content in a row below the Message
pep_customer_email_content $cust_email Can be used to change the entire content of the email
pep_customer_email_subject $admin_subject Can be used to change the email subject

Similar to above example, if we want to add date and time above the Product Name in the customer email, then the following code can be used:

add_filter( 'pep_before_product_name_in_customer_email', 'add_date_time_before_product_name', 10, 1 );
function add_date_time_before_product_name($cust_mail)
{
    $date_time_content =
    "<tr>
       <th style='width:25%;text-align:left'>" . __( 'Time', 'pep_text_domain' ) . " </th>
       <td style='width:75%'>:" . date('l jS \of F Y h:i:s A') .  "</td>
     </tr>";
    return $date_time_content.$cust_mail;
}

[space]
This code has to be either added in a custom plugin you create or functions.php of your theme. It’s pretty simple, so go ahead and try it out. And if you have any doubts of questions, I’m here to help! You can either use the comment section below or the support form on the plugin page to ask us any questions you have.

That’s all for now! But be sure to watch this space for more such customization tips. 🙂

Picture of Sumit Pore

Sumit Pore

2 Responses

  1. Guys,

    Get rid of the complacency that it is easily customizable. I’m just looking for where to change the email text. It is not mentioned on this page, it is not in woocommerce settings, it is not in your settings.

  2. Hi, brother

    I want to add the order number ID in the email sent to the administrator. How should I operate and where can I modify it

Leave a Reply

Your email address will not be published. Required fields are marked *

Get The Latest Updates

Subscribe to our Newsletter

A key to unlock the world of open-source. We promise not to spam your inbox.

Suggested Reads

Join our 55,000+ Subscribers

    The Wisdm Digest delivers all the latest news, and resources from the world of open-source businesses to your inbox.

    Suggested Reads