From 7891105ce128aa740da91a44f9582fc9d3cf5b67 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 1 Nov 2011 14:12:18 +0000 Subject: [PATCH] Added ability to show order meta in emails - shows coupons by default. Closes #96. --- readme.txt | 15 ++++----- templates/emails/customer_completed_order.php | 4 +-- templates/emails/customer_pay_for_order.php | 4 +-- .../emails/customer_processing_order.php | 4 +-- templates/emails/new_order.php | 4 +-- woocommerce_emails.php | 31 ++++++++++++++++++- 6 files changed, 42 insertions(+), 20 deletions(-) diff --git a/readme.txt b/readme.txt index 37d1044b53c..9caa129d0a5 100644 --- a/readme.txt +++ b/readme.txt @@ -83,20 +83,21 @@ Yes you can! Join in on our GitHub repository :) https://github.com/woothemes/wo == Changelog == = 1.1.4 - xx/10/2011 = +* Added quick status change buttons (processing/complete) to orders panel +* Ability to preview email templates +* Option to add logout link to my account menu +* Added ability to show meta (custom fields) on order emails - useful for plugins +* Added order details to thankyou page +* Added basic rss feeds for products and product categories +* Added functions which show tax/vat conditionally +* Made use of transients to store average ratings and improve performance * Edit category - image fix * Order Complete email heading fix * 100% discount when price excludes tax logic fix * Download urls use site_url instead of home_url so installs in subdirectories are handled correctly -* Option to add logout link to my account menu -* Ability to preview email templates -* Added order details to thankyou page -* Added basic rss feeds for products and product categories -* Added functions which show tax/vat conditionally * Fixed variations - Incorrectly used instead $product_custom_fields of $parent_custom_fields -* Made use of transients to store average ratings and improve performance * Adding cart item resets shipping - so free shipping etc is selected when going over a threshold * Changes to shipping calc - if no rates are found, but the user did not enter a state/postcode, it asks them to do so. -* Added quick status change buttons (processing/complete) to orders panel * Fix for adding sites in multisite * Dashboard chart now ignores 'pending' orders * Fixed dashboard report range diff --git a/templates/emails/customer_completed_order.php b/templates/emails/customer_completed_order.php index c579fa40b0f..28f7960129b 100644 --- a/templates/emails/customer_completed_order.php +++ b/templates/emails/customer_completed_order.php @@ -41,9 +41,7 @@ -customer_note) : ?> -

customer_note; ?>

- +

diff --git a/templates/emails/customer_pay_for_order.php b/templates/emails/customer_pay_for_order.php index 652487d9550..ccc94974f33 100644 --- a/templates/emails/customer_pay_for_order.php +++ b/templates/emails/customer_pay_for_order.php @@ -41,8 +41,6 @@ -customer_note) : ?> -

customer_note; ?>

- + \ No newline at end of file diff --git a/templates/emails/customer_processing_order.php b/templates/emails/customer_processing_order.php index ff9732e73c6..5f464c169a0 100644 --- a/templates/emails/customer_processing_order.php +++ b/templates/emails/customer_processing_order.php @@ -41,9 +41,7 @@ -customer_note) : ?> -

customer_note; ?>

- +

diff --git a/templates/emails/new_order.php b/templates/emails/new_order.php index 5171096a19e..c8d5dd69263 100644 --- a/templates/emails/new_order.php +++ b/templates/emails/new_order.php @@ -41,9 +41,7 @@ -customer_note) : ?> -

customer_note; ?>

- +

diff --git a/woocommerce_emails.php b/woocommerce_emails.php index 354ba0fe4d4..268e299a233 100644 --- a/woocommerce_emails.php +++ b/woocommerce_emails.php @@ -276,4 +276,33 @@ Gothica minim lectores demonstraverunt ut soluta. Sequitur quam exerci veniam al exit; endif; -} \ No newline at end of file +} + +/** + * Add order meta to email templates + **/ +add_action('woocommerce_email_after_order_table', 'woocommerce_email_order_meta', 10, 2); + +function woocommerce_email_order_meta( $order, $sent_to_admin ) { + + $meta = array(); + $show_fields = apply_filters('woocommerce_email_order_meta_keys', array('coupons'), $sent_to_admin); + + if ($order->customer_note) : + $meta[__('Note:', 'woothemes')] = wptexturize($order->customer_note); + endif; + + if ($show_fields) foreach ($show_fields as $field) : + + $value = get_post_meta( $order->id, $field, true ); + if ($value) $meta[ucwords(esc_attr($field))] = wptexturize($value); + + endforeach; + + if (sizeof($meta)>0) : + echo '

'.__('Order information', 'woothemes').'

'; + foreach ($meta as $key=>$value) : + echo '

'.$key.': '.$value.'

'; + endforeach; + endif; +}