Reputation: 2897
I've seen many articles about WooCommerce
email customization, but I can't find any that explains how to actually modify the page structure of the emails. For my project I need to add new page elements containing text and images. I want to actually build my emails as I would build a page.
Echoing stuff in email templates doesn't seem to work though. If I take templates/emails/customer-completed-order.php
, echo things in it then preview the result using Email Log plugin, it doesn't make any difference: my echos
don't render.
Are WooCommerce emails actually impossible to customize in depth?
Upvotes: 0
Views: 6522
Reputation: 790
In theme functions.php
, please create a two hook to add new content or apply HTML tags:
function add_order_email_instructions( $order, $sent_to_admin )
{
$order_id = $order->get_id();
if(!$sent_to_admin)
{
//Your message or code
}
else
{
//Your message or code
}
}
add_action( 'woocommerce_email_before_order_table', 'add_order_email_instructions', 10, 2 );
add_filter( 'woocommerce_email_headers', 'new_order_reply_to_admin_header', 20, 3 );
function new_order_reply_to_admin_header( $header, $email_id, $order )
{
if ( $email_id === 'new_order' ){
$email = new WC_Email($email_id);
$header = 'MIME-Version: 1.0' . "\r\n";
$header = 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
}
return $header;
}
Upvotes: -1
Reputation: 1774
Woocommerce emails can be customized but only to certain extent.
Content of any single email are strucuted in a little complicated manner.
E.g. The header part of the email is rendered from file email-header.php
. Footer part of the email is rendered from file email-footer.php
. Again for each different type of there are different template files, such as customer-invoice.php
, customer-new-account.php
, customer-processing-order.php
etc. Contents of the emails are also called from different hooks and functions. Again all the email elements are embeded with inline styles. These styles are defined in yeat another file email-styles.php
. Strange you can't easily find reference of this file in any of the email templates.
Regarding adding additional content/information in the emails should be possible.
Upvotes: 1
Reputation: 2343
Go to this folder:
plugin/WooCommerce/template/emails
copy the folder emails
to your theme folder then modify php files in emails
folder
If your change not actually work check this article:
https://docs.woothemes.com/document/template-structure/
also some plugin available for create custom Email template
Upvotes: 3