Humanize admin cancelled order emails

This commit is contained in:
Gerhard Potgieter 2018-08-23 09:38:16 +02:00
parent 903523638a
commit 2ce1262f69
4 changed files with 60 additions and 53 deletions

View File

@ -33,9 +33,10 @@ if ( ! class_exists( 'WC_Email_Cancelled_Order', false ) ) :
$this->template_html = 'emails/admin-cancelled-order.php';
$this->template_plain = 'emails/plain/admin-cancelled-order.php';
$this->placeholders = array(
'{site_title}' => $this->get_blogname(),
'{order_date}' => '',
'{order_number}' => '',
'{site_title}' => $this->get_blogname(),
'{order_date}' => '',
'{order_number}' => '',
'{order_billing_full_name}' => '',
);
// Triggers for this email.
@ -56,7 +57,7 @@ if ( ! class_exists( 'WC_Email_Cancelled_Order', false ) ) :
* @return string
*/
public function get_default_subject() {
return __( '[{site_title}] Cancelled order ({order_number})', 'woocommerce' );
return __( '{site_title}: {order_billing_full_name} has cancelled order {order_number}', 'woocommerce' );
}
/**
@ -66,7 +67,7 @@ if ( ! class_exists( 'WC_Email_Cancelled_Order', false ) ) :
* @return string
*/
public function get_default_heading() {
return __( 'Cancelled order', 'woocommerce' );
return __( 'Order Cancelled: {order_number}', 'woocommerce' );
}
/**
@ -83,9 +84,10 @@ if ( ! class_exists( 'WC_Email_Cancelled_Order', false ) ) :
}
if ( is_a( $order, 'WC_Order' ) ) {
$this->object = $order;
$this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
$this->placeholders['{order_number}'] = $this->object->get_order_number();
$this->object = $order;
$this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
$this->placeholders['{order_number}'] = $this->object->get_order_number();
$this->placeholders['{order_billing_full_name}'] = $this->object->get_formatted_billing_full_name();
}
if ( $this->is_enabled() && $this->get_recipient() ) {
@ -98,7 +100,6 @@ if ( ! class_exists( 'WC_Email_Cancelled_Order', false ) ) :
/**
* Get content html.
*
* @access public
* @return string
*/
public function get_content_html() {

View File

@ -10,45 +10,50 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates/Emails
* @version 2.5.0
* @version 3.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
/**
* @hooked WC_Emails::email_header() Output the email header
*/
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
/*
* @hooked WC_Emails::email_header() Output the email header
*/
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
<p><?php printf( __( 'The order #%1$s from %2$s has been cancelled. The order was as follows:', 'woocommerce' ), $order->get_order_number(), $order->get_formatted_billing_full_name() ); ?></p>
<?php /* translators: %1$s: Customer full name. %2$s: Order numer */ ?>
<p><?php printf( __( 'Alas. Just to let you know -- %1$s has cancelled order %2$s:', 'woocommerce' ), $order->get_formatted_billing_full_name(), $order->get_order_number() ); ?></p><?php // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped ?>
<?php
<?php
/**
* @hooked WC_Emails::order_details() Shows the order details table.
* @hooked WC_Structured_Data::generate_order_data() Generates structured data.
* @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
* @since 2.5.0
*/
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
/*
* @hooked WC_Emails::order_details() Shows the order details table.
* @hooked WC_Structured_Data::generate_order_data() Generates structured data.
* @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
* @since 2.5.0
*/
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );
/**
* @hooked WC_Emails::order_meta() Shows order meta data.
*/
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
/*
* @hooked WC_Emails::order_meta() Shows order meta data.
*/
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
/**
* @hooked WC_Emails::customer_details() Shows customer details
* @hooked WC_Emails::email_address() Shows email address
*/
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
/*
* @hooked WC_Emails::customer_details() Shows customer details
* @hooked WC_Emails::email_address() Shows email address
*/
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
?>
<p>
<?php _e( 'Read more about <a href="https://docs.woocommerce.com/document/managing-orders/">managing orders</a>, or get tips for <a href="https://woocommerce.com/2018/03/10-ways-to-make-your-next-sale/">making your next sale</a>.', 'woocommerce' ); // phpcs:ignore WordPress.XSS.EscapeOutput ?>
</p>
<?php
/**
* @hooked WC_Emails::email_footer() Output the email footer
*/
do_action( 'woocommerce_email_footer', $email );
/*
* @hooked WC_Emails::email_footer() Output the email footer
*/
do_action( 'woocommerce_email_footer', $email );

View File

@ -39,7 +39,7 @@ do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_tex
/*
* @hooked WC_Emails::order_meta() Shows order meta data.
*/
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
/*
* @hooked WC_Emails::customer_details() Shows customer details
@ -47,7 +47,7 @@ do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_tex
*/
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
?>
<p><?php _esc_html_e( 'Woo! Over to you.', 'woocommerce' ); ?>
<p><?php _esc_html_e( 'Woo! Over to you.', 'woocommerce' ); ?></p>
<?php
/*

View File

@ -10,23 +10,23 @@
* happen. When this occurs the version of the template file will be bumped and
* the readme will list any important changes.
*
* @see https://docs.woocommerce.com/document/template-structure/
* @author WooThemes
* @package WooCommerce/Templates/Emails/Plain
* @version 2.5.0
* @see https://docs.woocommerce.com/document/template-structure/
* @package WooCommerce/Templates/Emails/Plain
* @version 3.5.0
*/
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
echo "= " . $email_heading . " =\n\n";
echo '= ' . $email_heading . " =\n\n"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
echo sprintf( __( 'The order #%1$s from %2$s has been cancelled. The order was as follows:', 'woocommerce' ), $order->get_order_number(), $order->get_formatted_billing_full_name() ) . "\n\n";
/* translators: %1$s: Customer full name. %2$s: Order numer */
echo printf( __( 'Alas. Just to let you know -- %1$s has cancelled order %2$s:', 'woocommerce' ), $order->get_formatted_billing_full_name(), $order->get_order_number() ) . "\n\n"; // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
/**
/*
* @hooked WC_Emails::order_details() Shows the order details table.
* @hooked WC_Structured_Data::generate_order_data() Generates structured data.
* @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
@ -36,17 +36,18 @@ do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_tex
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
/**
/*
* @hooked WC_Emails::order_meta() Shows order meta data.
*/
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );
/**
/*
* @hooked WC_Emails::customer_details() Shows customer details
* @hooked WC_Emails::email_address() Shows email address
*/
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
echo __( 'Read more about managing orders (https://docs.woocommerce.com/document/managing-orders/), or get tips for making your next sale (https://woocommerce.com/2018/03/10-ways-to-make-your-next-sale/)', 'woocommerce' ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped
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' ) ); // phpcs:ignore WordPress.XSS.EscapeOutput.OutputNotEscaped