Woocommerce add custom fields to email

Wow so here we are using the blog to document what I would like to remember!

A customer of mine desired to use their WordPress site to sell registrations for classes.  One of the things they desired was to add an autoresponder segment to the order confirmation email.

To achieve this I added an extra field to the product (using PODS) and then added that field to email_order_items_table.

1. First thing to do is create a child theme if you have not already created one, check out this blog on ElegantThemes.com to find out how and why.

2. In your files copy the file called /wp-content/plugins/woocommerce/templates/emails/email-order-items.php to /wp-content/themes/[YOUR THEME]/woocommerce/emails/email-order-items.php .

3. Add at the bottom of the file above the line that says “<?php endforeach; ?>” (the very last line) add

<tr>
            <td colspan=”3″ style=”text-align:left; vertical-align:middle; border: 1px solid #eee; font-family: ‘Helvetica Neue’, Helvetica, Roboto, Arial, sans-serif;”><p><?php echo get_post_meta($_product->id, ‘autoresponder’, true); ?></p></td>
</tr>

4. In your files copy the file called /wp-content/plugins/woocommerce/templates/emails/plain/email-order-items.php to /wp-content/themes/[YOUR THEME]/woocommerce/emails/plain/email-order-items.php .

5. at the bottom of that file above the line that says “echo “\n\n”; ” add

 echo get_post_meta($_product->id, ‘autoresponder’, true);

Save both files!!!!!!!

If you just change the files in their original place they will be over ridden with an upgrade and you will loose your changes.

Pin It on Pinterest