Merge branch 'email_customer_details_hook_backup' into email_customer_details_hook_2

Conflicts:
	includes/class-wc-emails.php
This commit is contained in:
Kathy Darling 2014-11-13 00:32:15 +01:00
commit cfeeb7e9c6
9 changed files with 81 additions and 76 deletions

View File

@ -87,6 +87,8 @@ class WC_Emails {
add_action( 'woocommerce_email_header', array( $this, 'email_header' ) );
add_action( 'woocommerce_email_footer', array( $this, 'email_footer' ) );
add_action( 'woocommerce_email_order_meta', array( $this, 'order_meta' ), 10, 3 );
add_action( 'woocommerce_email_customer_details', array( $this, 'customer_details' ), 10, 3 );
add_action( 'woocommerce_email_customer_details', array( $this, 'email_addresses' ), 10, 3 );
// Hooks for sending emails during store events
add_action( 'woocommerce_low_stock_notification', array( $this, 'low_stock' ) );
@ -295,6 +297,77 @@ class WC_Emails {
}
}
/**
* Add customer details to email templates.
*
* @access public
* @param mixed $order
* @param bool $sent_to_admin (default: false)
* @param bool $plain_text (default: false)
*/
function customer_details( $order, $sent_to_admin = false, $plain_text = false ) {
$meta = array();
$show_fields = array();
if ( $order->billing_email ) {
$show_fields['billing_email'] = array(
'label' => __( 'Email:', 'woocommerce' ),
'value' => wptexturize( $order->billing_email )
);
}
if ( $order->billing_phone ) {
$show_fields['billing_phone'] = array(
'label' => __( 'Tel:', 'woocommerce' ),
'value' => wptexturize( $order->billing_phone )
);
}
$show_fields = apply_filters( 'woocommerce_email_customer_details_keys', $show_fields, $sent_to_admin, $order );
if( $show_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 $heading . "\n\n";
foreach ( $show_fields as $field ) {
if ( isset( $field['label'] ) && isset( $field['value'] ) && $field['value'] ) {
echo $field['label'] . ': ' . $field['value'] . "\n";
}
}
} else {
echo '<h2>' . $heading . '</h2>';
foreach ( $show_fields as $field ) {
if ( isset( $field['label'] ) && isset( $field['value'] ) && $field['value'] ) {
echo '<p><strong>' . $field['label'] . ':</strong> ' . $field['value'] . '</p>';
}
}
}
}
}
/**
* Get the email addresses.
*
* @access public
* @return void
*/
function email_addresses( $order, $sent_to_admin = false, $plain_text = false ) {
wc_get_template( 'emails/email-addresses.php', array( 'order' => $order ) );
}
/**
* Get blog name formatted for emails
* @return string

View File

@ -52,15 +52,6 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php do_action( 'woocommerce_email_order_meta', $order, true, false ); ?>
<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2>
<?php if ( $order->billing_email ) : ?>
<p><strong><?php _e( 'Email:', 'woocommerce' ); ?></strong> <?php echo $order->billing_email; ?></p>
<?php endif; ?>
<?php if ( $order->billing_phone ) : ?>
<p><strong><?php _e( 'Tel:', 'woocommerce' ); ?></strong> <?php echo $order->billing_phone; ?></p>
<?php endif; ?>
<?php wc_get_template( 'emails/email-addresses.php', array( 'order' => $order ) ); ?>
<?php do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text ); ?>
<?php do_action( 'woocommerce_email_footer' ); ?>

View File

@ -52,15 +52,6 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text ); ?>
<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2>
<?php if ($order->billing_email) : ?>
<p><strong><?php _e( 'Email:', 'woocommerce' ); ?></strong> <?php echo $order->billing_email; ?></p>
<?php endif; ?>
<?php if ($order->billing_phone) : ?>
<p><strong><?php _e( 'Tel:', 'woocommerce' ); ?></strong> <?php echo $order->billing_phone; ?></p>
<?php endif; ?>
<?php wc_get_template( 'emails/email-addresses.php', array( 'order' => $order ) ); ?>
<?php do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text ); ?>
<?php do_action( 'woocommerce_email_footer' ); ?>

View File

@ -56,15 +56,6 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text ); ?>
<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2>
<?php if ($order->billing_email) : ?>
<p><strong><?php _e( 'Email:', 'woocommerce' ); ?></strong> <?php echo $order->billing_email; ?></p>
<?php endif; ?>
<?php if ($order->billing_phone) : ?>
<p><strong><?php _e( 'Tel:', 'woocommerce' ); ?></strong> <?php echo $order->billing_phone; ?></p>
<?php endif; ?>
<?php wc_get_template( 'emails/email-addresses.php', array( 'order' => $order ) ); ?>
<?php do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text ); ?>
<?php do_action( 'woocommerce_email_footer' ); ?>

View File

@ -52,15 +52,6 @@ if ( ! defined( 'ABSPATH' ) ) {
<?php do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text ); ?>
<h2><?php _e( 'Customer details', 'woocommerce' ); ?></h2>
<?php if ($order->billing_email) : ?>
<p><strong><?php _e( 'Email:', 'woocommerce' ); ?></strong> <?php echo $order->billing_email; ?></p>
<?php endif; ?>
<?php if ($order->billing_phone) : ?>
<p><strong><?php _e( 'Tel:', 'woocommerce' ); ?></strong> <?php echo $order->billing_phone; ?></p>
<?php endif; ?>
<?php wc_get_template( 'emails/email-addresses.php', array( 'order' => $order ) ); ?>
<?php do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text ); ?>
<?php do_action( 'woocommerce_email_footer' ); ?>

View File

@ -39,15 +39,7 @@ echo "\n****************************************************\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
echo __( 'Customer details', 'woocommerce' ) . "\n";
if ( $order->billing_email )
echo __( 'Email:', 'woocommerce' ); echo $order->billing_email . "\n";
if ( $order->billing_phone )
echo __( 'Tel:', 'woocommerce' ); ?> <?php echo $order->billing_phone . "\n";
wc_get_template( 'emails/plain/email-addresses.php', array( 'order' => $order ) );
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text );
echo "\n****************************************************\n\n";

View File

@ -38,15 +38,7 @@ echo "\n****************************************************\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
echo __( 'Your details', 'woocommerce' ) . "\n\n";
if ( $order->billing_email )
echo __( 'Email:', 'woocommerce' ); echo $order->billing_email . "\n";
if ( $order->billing_phone )
echo __( 'Tel:', 'woocommerce' ); ?> <?php echo $order->billing_phone . "\n";
wc_get_template( 'emails/plain/email-addresses.php', array( 'order' => $order ) );
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text );
echo "\n****************************************************\n\n";

View File

@ -46,15 +46,7 @@ echo "\n****************************************************\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
echo __( 'Your details', 'woocommerce' ) . "\n\n";
if ( $order->billing_email )
echo __( 'Email:', 'woocommerce' ); echo $order->billing_email . "\n";
if ( $order->billing_phone )
echo __( 'Tel:', 'woocommerce' ); ?> <?php echo $order->billing_phone . "\n";
wc_get_template( 'emails/plain/email-addresses.php', array( 'order' => $order ) );
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text );
echo "\n****************************************************\n\n";

View File

@ -38,15 +38,7 @@ echo "\n****************************************************\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
echo __( 'Your details', 'woocommerce' ) . "\n\n";
if ( $order->billing_email )
echo __( 'Email:', 'woocommerce' ); echo $order->billing_email . "\n";
if ( $order->billing_phone )
echo __( 'Tel:', 'woocommerce' ); ?> <?php echo $order->billing_phone . "\n";
wc_get_template( 'emails/plain/email-addresses.php', array( 'order' => $order ) );
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text );
echo "\n****************************************************\n\n";