Reputation: 75
we use Woocommerce to sell car parts. Very often a customer writes an (important) Message into the textfield during the order process. We get the "New Order" E-Mail from the System, but the message is not inlcuded. How do we have to change the E-Mail Template to recieve the message from the customer?
Thank you for help
Upvotes: 1
Views: 1373
Reputation: 420
For the future if someone else is looking for an answer. If you're looking to add the customer note to the new order email, you can just use one of the action hooks instead of overriding the email template:
// Hook this function into woocommerce_email_order_meta
add_action( 'woocommerce_email_order_meta', 'woo_add_customer_note_to_email', 10, 3 );
function woo_add_customer_note_to_email( $order, $is_admin, $plain_text = false ) {
// Retrieve the customer note as a variable from the $order array.
$customer_note = $order->get_customer_note();
// You want to send those only to the Admin, or only customers, modify here. Right now it's only sending to admin emails.
if ( !$is_admin || $is_admin && empty($customer_note) ) {
return;
}
// Setup our html markup for inclusion in the email. Note, you should inline your styles, which is best practice for HTML emails.
echo '<div style="font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; margin-top: 40px;"><h2 style=""color: #6a6057; display: block; font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif; font-size: 18px; font-weight: bold; line-height: 130%; margin: 0 0 18px; text-align: left;">Customer Notes</h2>';
echo '<blockquote><span style="color: #505050; font-family: "Helvetica Neue", Helvetica, Roboto, Arial, sans-serif;">' . wpautop( wptexturize( $customer_note ) ) . '</span></blockquote>';
echo '</div>';
}
Upvotes: 0
Reputation: 2775
You can configure some details of the confirmation email in the WooCommerce settings area in Wp-Admin section: WooCommerce -> Settings -> Emails.
Also you can edit template files here:
wp-content/plugins/woocommerce/templates/emails
Important: Do not edit files inside plugin directory, because then your changes will be lost with first plugin update. This template can be overridden by copying it to
yourtheme/woocommerce/emails/template_name.php
So you can edit template file and attach your textfield data to email.
Upvotes: 2