Added template files for the customer details list in emails. emails/email-customer-details.php

Closes #9253
This commit is contained in:
Mike Jolley 2015-11-02 10:41:05 +00:00
parent dfc1e0a625
commit 3ca5022649
5 changed files with 78 additions and 45 deletions

View File

@ -307,6 +307,15 @@ class WC_Emails {
}
}
/**
* Is customer detail field valid?
* @param array $field
* @return boolean
*/
public function customer_detail_field_is_valid( $field ) {
return isset( $field['label'] ) && ! empty( $field['value'] );
}
/**
* Add customer details to email templates.
*
@ -332,37 +341,13 @@ class WC_Emails {
);
}
$fields = apply_filters( 'woocommerce_email_customer_details_fields', $fields, $sent_to_admin, $order );
if ( $fields ) {
$heading = $sent_to_admin ? __( 'Customer details', 'woocommerce' ) : __( 'Your details', 'woocommerce' );
$heading = apply_filters( 'woocommerce_email_custom_details_header', $heading, $sent_to_admin, $order );
if ( $plain_text ) {
echo strtoupper( $heading ) . "\n\n";
foreach ( $fields as $field ) {
if ( isset( $field['label'] ) && isset( $field['value'] ) && $field['value'] ) {
echo $field['label'] . ': ' . $field['value'] . "\n";
}
}
} else {
echo '<h2>' . $heading . '</h2>';
foreach ( $fields as $field ) {
if ( isset( $field['label'] ) && isset( $field['value'] ) && $field['value'] ) {
echo '<p><strong>' . $field['label'] . ':</strong> <span class="text">' . $field['value'] . '</span></p>';
}
}
}
$fields = array_filter( apply_filters( 'woocommerce_email_customer_details_fields', $fields, $sent_to_admin, $order ), array( $this, 'customer_detail_field_is_valid' ) );
if ( $plain_text ) {
wc_get_template( 'emails/plain/email-customer-details.php', array( 'fields' => $fields ) );
} else {
wc_get_template( 'emails/email-customer-details.php', array( 'fields' => $fields ) );
}
}
/**

View File

@ -195,6 +195,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
* Dev - Template - New star ratings. The old one was 5 separate buttons. This new one consolidates the 5 options into one element making it leaner visually and more intuitive. Works in IE9+ with a graceful degradation for IE8.
* Dev - Template - Added `data-title` attribute to cart table.
* Dev - Template - Product archive anchors are now hooked into templates rather than hard coded.
* Dev - Template - Added template files for the customer details list in emails. emails/email-customer-details.php
* Dev - Allow wc_clean to support arrays.
* Dev - Added a manual update trigger for checkout.
* Dev - Added woocommerce_is_price_filter_active filter to Query class.

View File

@ -16,33 +16,22 @@
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
?><table id="addresses" cellspacing="0" cellpadding="0" style="width: 100%; vertical-align: top;" border="0">
<tr>
<td class="td" style="text-align:left; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%">
<h3><?php _e( 'Billing address', 'woocommerce' ); ?></h3>
<p class="text"><?php echo $order->get_formatted_billing_address(); ?></p>
</td>
<?php if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && ( $shipping = $order->get_formatted_shipping_address() ) ) : ?>
<td class="td" style="text-align:left; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%">
<h3><?php _e( 'Shipping address', 'woocommerce' ); ?></h3>
<td class="td" style="text-align:left; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" valign="top" width="50%">
<h3><?php _e( 'Shipping address', 'woocommerce' ); ?></h3>
<p class="text"><?php echo $shipping; ?></p>
</td>
<p class="text"><?php echo $shipping; ?></p>
</td>
<?php endif; ?>
</tr>
</table>

View File

@ -0,0 +1,30 @@
<?php
/**
* Additional Customer Details
*
* This is extra customer data which can be filtered by plugins. It outputs below the order item table.
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/email-addresses.php
*
* HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer)
* will need to copy the new files to your theme to maintain compatibility. We try to do this
* as little as possible, but it does happen. When this occurs the version of the template file will
* be bumped and the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates/Emails
* @version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
?>
<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2>
<ul>
<?php foreach ( $fields as $field ) : ?>
<li><strong><?php echo wp_kses_post( $field['label'] ); ?>:</strong> <span class="text"><?php echo wp_kses_post( $field['value'] ); ?></span></li>
<?php endforeach; ?>
</ul>

View File

@ -0,0 +1,28 @@
<?php
/**
* Additional Customer Details (plain)
*
* This is extra customer data which can be filtered by plugins. It outputs below the order item table.
*
* This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/email-addresses.php
*
* HOWEVER, on occasion WooCommerce will need to update template files and you (the theme developer)
* will need to copy the new files to your theme to maintain compatibility. We try to do this
* as little as possible, but it does happen. When this occurs the version of the template file will
* be bumped and the readme will list any important changes.
*
* @see http://docs.woothemes.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates/Emails/Plain
* @version 2.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
echo strtoupper( __( 'Customer details', 'woocommerce' ) ) . "\n\n";
foreach ( $fields as $field ) {
echo wp_kses_post( $field['label'] ) . ': ' . wp_kses_post( $field['value'] ) . "\n";
}