Fix address formatting and improve email appearance

Fixes #7484
This commit is contained in:
Mike Jolley 2015-02-19 13:57:20 +00:00
parent 966ca94e41
commit 09676934d6
12 changed files with 66 additions and 60 deletions

View File

@ -338,7 +338,7 @@ class WC_Emails {
if ( $plain_text ) {
echo $heading . "\n\n";
echo strtoupper( $heading ) . "\n\n";
foreach ( $fields as $field ) {
if ( isset( $field['label'] ) && isset( $field['value'] ) && $field['value'] ) {
@ -367,7 +367,11 @@ class WC_Emails {
* @return void
*/
public function email_addresses( $order, $sent_to_admin = false, $plain_text = false ) {
wc_get_template( 'emails/email-addresses.php', array( 'order' => $order ) );
if ( $plain_text ) {
wc_get_template( 'emails/plain/email-addresses.php', array( 'order' => $order ) );
} else {
wc_get_template( 'emails/email-addresses.php', array( 'order' => $order ) );
}
}
/**

View File

@ -138,9 +138,11 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
== Changelog ==
* Fix - Plain text address formatting.
* Fix - Detect shortcodes when saving URLs.
* Fix - Unhook wc_page_endpoint_title after it is ran once (main page title).
* Fix - Taxes save issue when page is paginated.
* Tweak - Text in plain text emails.
* Tweak - Improve category coupon message.
* Tweak - Don't download GeoIP Database until geolocation option is enabled in settings.

View File

@ -10,23 +10,22 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
echo $email_heading . "\n\n";
echo "= " . $email_heading . " =\n\n";
echo sprintf( __( 'The order #%d from %s has been cancelled. The order was as follows:', 'woocommerce' ), $order->id, $order->billing_first_name . ' ' . $order->billing_last_name ) . "\n\n";
echo "****************************************************\n\n";
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text );
echo sprintf( __( 'Order number: %s', 'woocommerce'), $order->get_order_number() ) . "\n";
echo sprintf( __( 'Order link: %s', 'woocommerce'), admin_url( 'post.php?post=' . $order->id . '&action=edit' ) ) . "\n";
echo sprintf( __( 'Order date: %s', 'woocommerce'), date_i18n( __( 'jS F Y', 'woocommerce' ), strtotime( $order->order_date ) ) ) . "\n";
echo strtoupper( sprintf( __( 'Order number: %s', 'woocommerce' ), $order->get_order_number() ) ) . "\n";
echo date_i18n( __( 'jS F Y', 'woocommerce' ), strtotime( $order->order_date ) ) . "\n";
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text );
echo "\n" . $order->email_order_items_table( false, true, '', '', '', true );
echo "----------\n\n";
echo "==========\n\n";
if ( $totals = $order->get_order_item_totals() ) {
foreach ( $totals as $total ) {
@ -34,12 +33,14 @@ if ( $totals = $order->get_order_item_totals() ) {
}
}
echo "\n****************************************************\n\n";
echo "\n" . sprintf( __( 'View order: %s', 'woocommerce'), admin_url( 'post.php?post=' . $order->id . '&action=edit' ) ) . "\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text );
echo "\n****************************************************\n\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );

View File

@ -11,36 +11,37 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
echo $email_heading . "\n\n";
echo "= " . $email_heading . " =\n\n";
echo sprintf( __( 'You have received an order from %s. The order is as follows:', 'woocommerce' ), $order->billing_first_name . ' ' . $order->billing_last_name ) . "\n\n";
echo sprintf( __( 'You have received an order from %s.', 'woocommerce' ), $order->billing_first_name . ' ' . $order->billing_last_name ) . "\n\n";
echo "****************************************************\n\n";
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text );
echo sprintf( __( 'Order number: %s', 'woocommerce'), $order->get_order_number() ) . "\n";
echo sprintf( __( 'Order link: %s', 'woocommerce'), admin_url( 'post.php?post=' . $order->id . '&action=edit' ) ) . "\n";
echo sprintf( __( 'Order date: %s', 'woocommerce'), date_i18n( __( 'jS F Y', 'woocommerce' ), strtotime( $order->order_date ) ) ) . "\n";
echo strtoupper( sprintf( __( 'Order number: %s', 'woocommerce' ), $order->get_order_number() ) ) . "\n";
echo date_i18n( __( 'jS F Y', 'woocommerce' ), strtotime( $order->order_date ) ) . "\n";
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text );
echo "\n" . $order->email_order_items_table( false, true, '', '', '', true );
echo "----------\n\n";
echo "==========\n\n";
if ( $totals = $order->get_order_item_totals() ) {
foreach ( $totals as $total ) {
echo $total['label'] . "\t " . $total['value'] . "\n";
echo $total['label'] . " " . $total['value'] . "\n";
}
}
echo "\n****************************************************\n\n";
echo "\n" . sprintf( __( 'View order: %s', 'woocommerce'), admin_url( 'post.php?post=' . $order->id . '&action=edit' ) ) . "\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text );
echo "\n****************************************************\n\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );

View File

@ -11,22 +11,22 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
echo $email_heading . "\n\n";
echo "= " . $email_heading . " =\n\n";
echo sprintf( __( "Hi there. Your recent order on %s has been completed. Your order details are shown below for your reference:", 'woocommerce' ), get_option( 'blogname' ) ) . "\n\n";
echo "****************************************************\n\n";
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text );
echo sprintf( __( 'Order number: %s', 'woocommerce'), $order->get_order_number() ) . "\n";
echo sprintf( __( 'Order date: %s', 'woocommerce'), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ) . "\n";
echo strtoupper( sprintf( __( 'Order number: %s', 'woocommerce' ), $order->get_order_number() ) ) . "\n";
echo date_i18n( __( 'jS F Y', 'woocommerce' ), strtotime( $order->order_date ) ) . "\n";
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text );
echo "\n" . $order->email_order_items_table( true, false, true, '', '', true );
echo "----------\n\n";
echo "==========\n\n";
if ( $totals = $order->get_order_item_totals() ) {
foreach ( $totals as $total ) {
@ -34,12 +34,12 @@ if ( $totals = $order->get_order_item_totals() ) {
}
}
echo "\n****************************************************\n\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text );
echo "\n****************************************************\n\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );

View File

@ -11,17 +11,17 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
echo $email_heading . "\n\n";
echo "= " . $email_heading . " =\n\n";
if ( $order->has_status( 'pending' ) )
echo sprintf( __( 'An order has been created for you on %s. To pay for this order please use the following link: %s', 'woocommerce' ), get_bloginfo( 'name', 'display' ), $order->get_checkout_payment_url() ) . "\n\n";
echo "****************************************************\n\n";
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text );
echo sprintf( __( 'Order number: %s', 'woocommerce'), $order->get_order_number() ) . "\n";
echo sprintf( __( 'Order date: %s', 'woocommerce'), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ) . "\n";
echo strtoupper( sprintf( __( 'Order number: %s', 'woocommerce' ), $order->get_order_number() ) ) . "\n";
echo date_i18n( __( 'jS F Y', 'woocommerce' ), strtotime( $order->order_date ) ) . "\n";
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text );
@ -39,7 +39,7 @@ switch ( $order->get_status() ) {
break;
}
echo "----------\n\n";
echo "==========\n\n";
if ( $totals = $order->get_order_item_totals() ) {
foreach ( $totals as $total ) {
@ -47,7 +47,7 @@ if ( $totals = $order->get_order_item_totals() ) {
}
}
echo "\n****************************************************\n\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );

View File

@ -11,7 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
echo $email_heading . "\n\n";
echo "= " . $email_heading . " =\n\n";
echo sprintf( __( "Thanks for creating an account on %s. Your username is <strong>%s</strong>.", 'woocommerce' ), $blogname, $user_login ) . "\n\n";
@ -20,6 +20,6 @@ if ( get_option( 'woocommerce_registration_generate_password' ) === 'yes' && $pa
echo sprintf( __( 'You can access your account area to view your orders and change your password here: %s.', 'woocommerce' ), wc_get_page_permalink( 'myaccount' ) ) . "\n\n";
echo "\n****************************************************\n\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );

View File

@ -11,7 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
echo $email_heading . "\n\n";
echo "= " . $email_heading . " =\n\n";
echo __( "Hello, a note has just been added to your order:", 'woocommerce' ) . "\n\n";
@ -23,18 +23,18 @@ echo "----------\n\n";
echo __( "For your reference, your order details are shown below.", 'woocommerce' ) . "\n\n";
echo "****************************************************\n\n";
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text );
echo sprintf( __( 'Order number: %s', 'woocommerce'), $order->get_order_number() ) . "\n";
echo sprintf( __( 'Order date: %s', 'woocommerce'), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ) . "\n";
echo strtoupper( sprintf( __( 'Order number: %s', 'woocommerce' ), $order->get_order_number() ) ) . "\n";
echo date_i18n( __( 'jS F Y', 'woocommerce' ), strtotime( $order->order_date ) ) . "\n";
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text );
echo "\n" . $order->email_order_items_table( $order->is_download_permitted(), true, '', '', '', true );
echo "----------\n\n";
echo "==========\n\n";
if ( $totals = $order->get_order_item_totals() ) {
foreach ( $totals as $total ) {
@ -42,12 +42,12 @@ if ( $totals = $order->get_order_item_totals() ) {
}
}
echo "\n****************************************************\n\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text );
echo "\n****************************************************\n\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );

View File

@ -11,22 +11,22 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
echo $email_heading . "\n\n";
echo "= " . $email_heading . " =\n\n";
echo __( "Your order has been received and is now being processed. Your order details are shown below for your reference:", 'woocommerce' ) . "\n\n";
echo "****************************************************\n\n";
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text );
echo sprintf( __( 'Order number: %s', 'woocommerce'), $order->get_order_number() ) . "\n";
echo sprintf( __( 'Order date: %s', 'woocommerce'), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ) . "\n";
echo strtoupper( sprintf( __( 'Order number: %s', 'woocommerce' ), $order->get_order_number() ) ) . "\n";
echo date_i18n( __( 'jS F Y', 'woocommerce' ), strtotime( $order->order_date ) ) . "\n";
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text );
echo "\n" . $order->email_order_items_table( $order->is_download_permitted(), true, $order->has_status( 'processing' ), '', '', true );
echo "----------\n\n";
echo "==========\n\n";
if ( $totals = $order->get_order_item_totals() ) {
foreach ( $totals as $total ) {
@ -34,12 +34,12 @@ if ( $totals = $order->get_order_item_totals() ) {
}
}
echo "\n****************************************************\n\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
do_action( 'woocommerce_email_after_order_table', $order, $sent_to_admin, $plain_text );
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text );
echo "\n****************************************************\n\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );

View File

@ -11,7 +11,7 @@ if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
}
echo $email_heading . "\n\n";
echo "= " . $email_heading . " =\n\n";
echo __( 'Someone requested that the password be reset for the following account:', 'woocommerce' ) . "\r\n\r\n";
echo esc_url( network_home_url( '/' ) ) . "\r\n\r\n";
@ -21,6 +21,6 @@ echo __( 'To reset your password, visit the following address:', 'woocommerce' )
echo esc_url( add_query_arg( array( 'key' => $reset_key, 'login' => $user_login ), wc_get_endpoint_url( 'lost-password', '', wc_get_page_permalink( 'myaccount' ) ) ) ) . "\r\n";
echo "\n****************************************************\n\n";
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );

View File

@ -8,15 +8,13 @@
*/
if ( ! defined( 'ABSPATH' ) ) {
exit; // Exit if accessed directly
exit;
}
echo "\n" . __( 'Billing address', 'woocommerce' ) . ":\n";
echo preg_replace( '#<br\s*/?>#i', "\n", $order->get_formatted_billing_address() ) . "\n\n";
echo "\n" . strtoupper( __( 'Billing address', 'woocommerce' ) ) . "\n\n";
echo preg_replace( '#<br\s*/?>#i', "\n", $order->get_formatted_billing_address() ) . "\n";
if ( ! wc_ship_to_billing_address_only() && $order->needs_shipping_address() && ( $shipping = $order->get_formatted_shipping_address() ) ) {
echo __( 'Shipping address', 'woocommerce' ) . ":\n";
echo preg_replace( '#<br\s*/?>#i', "\n", $shipping ) . "\n\n";
echo "\n" . strtoupper( __( 'Shipping address', 'woocommerce' ) ) . "\n\n";
echo preg_replace( '#<br\s*/?>#i', "\n\t", $shipping ) . "\n";
}

View File

@ -29,7 +29,7 @@ foreach ( $items as $item_id => $item ) :
do_action( 'woocommerce_order_item_meta_start', $item_id, $item, $order );
// Variation
echo $item_meta->meta ? "\n" . $item_meta->display( true, true ) : '';
echo ( $item_meta_content = $item_meta->display( true, true ) ) ? "\n" . $item_meta_content : '';
// Quantity
echo "\n" . sprintf( __( 'Quantity: %s', 'woocommerce' ), $item['qty'] );