parent
9ac43ec4d4
commit
48b93b937f
|
@ -63,11 +63,13 @@ class WC_Emails {
|
|||
'woocommerce_order_status_pending_to_processing',
|
||||
'woocommerce_order_status_pending_to_completed',
|
||||
'woocommerce_order_status_pending_to_cancelled',
|
||||
'woocommerce_order_status_pending_to_failed',
|
||||
'woocommerce_order_status_pending_to_on-hold',
|
||||
'woocommerce_order_status_failed_to_processing',
|
||||
'woocommerce_order_status_failed_to_completed',
|
||||
'woocommerce_order_status_on-hold_to_processing',
|
||||
'woocommerce_order_status_on-hold_to_cancelled',
|
||||
'woocommerce_order_status_on-hold_to_failed',
|
||||
'woocommerce_order_status_completed',
|
||||
'woocommerce_order_fully_refunded',
|
||||
'woocommerce_order_partially_refunded',
|
||||
|
@ -121,15 +123,16 @@ class WC_Emails {
|
|||
// Include email classes
|
||||
include_once( 'emails/class-wc-email.php' );
|
||||
|
||||
$this->emails['WC_Email_New_Order'] = include( 'emails/class-wc-email-new-order.php' );
|
||||
$this->emails['WC_Email_Cancelled_Order'] = include( 'emails/class-wc-email-cancelled-order.php' );
|
||||
$this->emails['WC_Email_Customer_Processing_Order'] = include( 'emails/class-wc-email-customer-processing-order.php' );
|
||||
$this->emails['WC_Email_Customer_Completed_Order'] = include( 'emails/class-wc-email-customer-completed-order.php' );
|
||||
$this->emails['WC_Email_Customer_Refunded_Order'] = include( 'emails/class-wc-email-customer-refunded-order.php' );
|
||||
$this->emails['WC_Email_Customer_Invoice'] = include( 'emails/class-wc-email-customer-invoice.php' );
|
||||
$this->emails['WC_Email_Customer_Note'] = include( 'emails/class-wc-email-customer-note.php' );
|
||||
$this->emails['WC_Email_Customer_Reset_Password'] = include( 'emails/class-wc-email-customer-reset-password.php' );
|
||||
$this->emails['WC_Email_Customer_New_Account'] = include( 'emails/class-wc-email-customer-new-account.php' );
|
||||
$this->emails['WC_Email_New_Order'] = include( 'emails/class-wc-email-new-order.php' );
|
||||
$this->emails['WC_Email_Cancelled_Order'] = include( 'emails/class-wc-email-cancelled-order.php' );
|
||||
$this->emails['WC_Email_Failed_Order'] = include( 'emails/class-wc-email-failed-order.php' );
|
||||
$this->emails['WC_Email_Customer_Processing_Order'] = include( 'emails/class-wc-email-customer-processing-order.php' );
|
||||
$this->emails['WC_Email_Customer_Completed_Order'] = include( 'emails/class-wc-email-customer-completed-order.php' );
|
||||
$this->emails['WC_Email_Customer_Refunded_Order'] = include( 'emails/class-wc-email-customer-refunded-order.php' );
|
||||
$this->emails['WC_Email_Customer_Invoice'] = include( 'emails/class-wc-email-customer-invoice.php' );
|
||||
$this->emails['WC_Email_Customer_Note'] = include( 'emails/class-wc-email-customer-note.php' );
|
||||
$this->emails['WC_Email_Customer_Reset_Password'] = include( 'emails/class-wc-email-customer-reset-password.php' );
|
||||
$this->emails['WC_Email_Customer_New_Account'] = include( 'emails/class-wc-email-customer-new-account.php' );
|
||||
|
||||
$this->emails = apply_filters( 'woocommerce_email_classes', $this->emails );
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_Cancelled_Order' ) ) :
|
||||
|
@ -22,15 +22,12 @@ class WC_Email_Cancelled_Order extends WC_Email {
|
|||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
public function __construct() {
|
||||
$this->id = 'cancelled_order';
|
||||
$this->title = __( 'Cancelled order', 'woocommerce' );
|
||||
$this->description = __( 'Cancelled order emails are sent to the recipient list when orders have been marked cancelled (if they were previously processing or on-hold).', 'woocommerce' );
|
||||
|
||||
$this->description = __( 'Cancelled order emails are sent to the recipient(s) below when orders have been marked cancelled (if they were previously processing or on-hold).', 'woocommerce' );
|
||||
$this->heading = __( 'Cancelled order', 'woocommerce' );
|
||||
$this->subject = __( '[{site_title}] Cancelled order ({order_number})', 'woocommerce' );
|
||||
|
||||
$this->template_html = 'emails/admin-cancelled-order.php';
|
||||
$this->template_plain = 'emails/plain/admin-cancelled-order.php';
|
||||
|
||||
|
@ -42,22 +39,18 @@ class WC_Email_Cancelled_Order extends WC_Email {
|
|||
parent::__construct();
|
||||
|
||||
// Other settings
|
||||
$this->recipient = $this->get_option( 'recipient' );
|
||||
|
||||
if ( ! $this->recipient )
|
||||
$this->recipient = get_option( 'admin_email' );
|
||||
$this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger.
|
||||
*/
|
||||
function trigger( $order_id ) {
|
||||
|
||||
public function trigger( $order_id ) {
|
||||
if ( $order_id ) {
|
||||
$this->object = wc_get_order( $order_id );
|
||||
|
||||
$this->object = wc_get_order( $order_id );
|
||||
$this->find['order-date'] = '{order_date}';
|
||||
$this->find['order-number'] = '{order_number}';
|
||||
|
||||
$this->replace['order-date'] = date_i18n( wc_date_format(), strtotime( $this->object->order_date ) );
|
||||
$this->replace['order-number'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
|
@ -74,7 +67,7 @@ class WC_Email_Cancelled_Order extends WC_Email {
|
|||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function get_content_html() {
|
||||
public function get_content_html() {
|
||||
ob_start();
|
||||
wc_get_template( $this->template_html, array(
|
||||
'order' => $this->object,
|
||||
|
@ -91,7 +84,7 @@ class WC_Email_Cancelled_Order extends WC_Email {
|
|||
*
|
||||
* @return string
|
||||
*/
|
||||
function get_content_plain() {
|
||||
public function get_content_plain() {
|
||||
ob_start();
|
||||
wc_get_template( $this->template_plain, array(
|
||||
'order' => $this->object,
|
||||
|
@ -105,7 +98,7 @@ class WC_Email_Cancelled_Order extends WC_Email {
|
|||
/**
|
||||
* Initialise settings form fields.
|
||||
*/
|
||||
function init_form_fields() {
|
||||
public function init_form_fields() {
|
||||
$this->form_fields = array(
|
||||
'enabled' => array(
|
||||
'title' => __( 'Enable/Disable', 'woocommerce' ),
|
||||
|
|
|
@ -0,0 +1,144 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_Failed_Order' ) ) :
|
||||
|
||||
/**
|
||||
* Failed Order Email
|
||||
*
|
||||
* An email sent to the admin when payment fails to go through.
|
||||
*
|
||||
* @class WC_Email_Failed_Order
|
||||
* @version 2.5.0
|
||||
* @package WooCommerce/Classes/Emails
|
||||
* @author WooThemes
|
||||
* @extends WC_Email
|
||||
*/
|
||||
class WC_Email_Failed_Order extends WC_Email {
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->id = 'failed_order';
|
||||
$this->title = __( 'Failed order', 'woocommerce' );
|
||||
$this->description = __( 'Failed order emails are sent to the recipient(s) below when orders have been marked failed (if they were previously processing or on-hold).', 'woocommerce' );
|
||||
$this->heading = __( 'Failed order', 'woocommerce' );
|
||||
$this->subject = __( '[{site_title}] Failed order ({order_number})', 'woocommerce' );
|
||||
$this->template_html = 'emails/admin-failed-order.php';
|
||||
$this->template_plain = 'emails/plain/admin-failed-order.php';
|
||||
|
||||
// Triggers for this email
|
||||
add_action( 'woocommerce_order_status_pending_to_failed_notification', array( $this, 'trigger' ) );
|
||||
add_action( 'woocommerce_order_status_on-hold_to_failed_notification', array( $this, 'trigger' ) );
|
||||
|
||||
// Call parent constructor
|
||||
parent::__construct();
|
||||
|
||||
// Other settings
|
||||
$this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger.
|
||||
*/
|
||||
public function trigger( $order_id ) {
|
||||
if ( $order_id ) {
|
||||
$this->object = wc_get_order( $order_id );
|
||||
$this->find['order-date'] = '{order_date}';
|
||||
$this->find['order-number'] = '{order_number}';
|
||||
$this->replace['order-date'] = date_i18n( wc_date_format(), strtotime( $this->object->order_date ) );
|
||||
$this->replace['order-number'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
|
||||
return;
|
||||
}
|
||||
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
/**
|
||||
* get_content_html function.
|
||||
*
|
||||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_html() {
|
||||
ob_start();
|
||||
wc_get_template( $this->template_html, array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'sent_to_admin' => true,
|
||||
'plain_text' => false,
|
||||
'email' => $this
|
||||
) );
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content plain.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_plain() {
|
||||
ob_start();
|
||||
wc_get_template( $this->template_plain, array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'sent_to_admin' => true,
|
||||
'plain_text' => true
|
||||
) );
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise settings form fields.
|
||||
*/
|
||||
public function init_form_fields() {
|
||||
$this->form_fields = array(
|
||||
'enabled' => array(
|
||||
'title' => __( 'Enable/Disable', 'woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable this email notification', 'woocommerce' ),
|
||||
'default' => 'yes'
|
||||
),
|
||||
'recipient' => array(
|
||||
'title' => __( 'Recipient(s)', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to <code>%s</code>.', 'woocommerce' ), esc_attr( get_option('admin_email') ) ),
|
||||
'placeholder' => '',
|
||||
'default' => ''
|
||||
),
|
||||
'subject' => array(
|
||||
'title' => __( 'Subject', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'description' => sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', 'woocommerce' ), $this->subject ),
|
||||
'placeholder' => '',
|
||||
'default' => ''
|
||||
),
|
||||
'heading' => array(
|
||||
'title' => __( 'Email Heading', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.', 'woocommerce' ), $this->heading ),
|
||||
'placeholder' => '',
|
||||
'default' => ''
|
||||
),
|
||||
'email_type' => array(
|
||||
'title' => __( 'Email type', 'woocommerce' ),
|
||||
'type' => 'select',
|
||||
'description' => __( 'Choose which format of email to send.', 'woocommerce' ),
|
||||
'default' => 'html',
|
||||
'class' => 'email_type wc-enhanced-select',
|
||||
'options' => $this->get_email_type_options()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new WC_Email_Failed_Order();
|
|
@ -1,7 +1,7 @@
|
|||
<?php
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_New_Order' ) ) :
|
||||
|
@ -22,15 +22,12 @@ class WC_Email_New_Order extends WC_Email {
|
|||
/**
|
||||
* Constructor
|
||||
*/
|
||||
function __construct() {
|
||||
|
||||
public function __construct() {
|
||||
$this->id = 'new_order';
|
||||
$this->title = __( 'New order', 'woocommerce' );
|
||||
$this->description = __( 'New order emails are sent to the recipient list when an order is received.', 'woocommerce' );
|
||||
|
||||
$this->description = __( 'New order emails are sent to the recipient(s) below when an order is received.', 'woocommerce' );
|
||||
$this->heading = __( 'New customer order', 'woocommerce' );
|
||||
$this->subject = __( '[{site_title}] New customer order ({order_number}) - {order_date}', 'woocommerce' );
|
||||
|
||||
$this->template_html = 'emails/admin-new-order.php';
|
||||
$this->template_plain = 'emails/plain/admin-new-order.php';
|
||||
|
||||
|
@ -46,23 +43,17 @@ class WC_Email_New_Order extends WC_Email {
|
|||
parent::__construct();
|
||||
|
||||
// Other settings
|
||||
$this->recipient = $this->get_option( 'recipient' );
|
||||
|
||||
if ( ! $this->recipient )
|
||||
$this->recipient = get_option( 'admin_email' );
|
||||
$this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger.
|
||||
*/
|
||||
function trigger( $order_id ) {
|
||||
|
||||
public function trigger( $order_id ) {
|
||||
if ( $order_id ) {
|
||||
$this->object = wc_get_order( $order_id );
|
||||
|
||||
$this->object = wc_get_order( $order_id );
|
||||
$this->find['order-date'] = '{order_date}';
|
||||
$this->find['order-number'] = '{order_number}';
|
||||
|
||||
$this->replace['order-date'] = date_i18n( wc_date_format(), strtotime( $this->object->order_date ) );
|
||||
$this->replace['order-number'] = $this->object->get_order_number();
|
||||
}
|
||||
|
@ -80,7 +71,7 @@ class WC_Email_New_Order extends WC_Email {
|
|||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function get_content_html() {
|
||||
public function get_content_html() {
|
||||
ob_start();
|
||||
wc_get_template( $this->template_html, array(
|
||||
'order' => $this->object,
|
||||
|
@ -98,7 +89,7 @@ class WC_Email_New_Order extends WC_Email {
|
|||
* @access public
|
||||
* @return string
|
||||
*/
|
||||
function get_content_plain() {
|
||||
public function get_content_plain() {
|
||||
ob_start();
|
||||
wc_get_template( $this->template_plain, array(
|
||||
'order' => $this->object,
|
||||
|
@ -112,7 +103,7 @@ class WC_Email_New_Order extends WC_Email {
|
|||
/**
|
||||
* Initialise settings form fields
|
||||
*/
|
||||
function init_form_fields() {
|
||||
public function init_form_fields() {
|
||||
$this->form_fields = array(
|
||||
'enabled' => array(
|
||||
'title' => __( 'Enable/Disable', 'woocommerce' ),
|
||||
|
|
|
@ -165,6 +165,7 @@ Yes you can! Join in on our [GitHub repository](http://github.com/woothemes/wooc
|
|||
* Feature - Added terms and conditions checkbox to pay page.
|
||||
* Feature - Password strength indicators.
|
||||
* Feature - Added 'pay' link to order screen.
|
||||
* Feature - Added admin order/payment failed notification.
|
||||
* Fix - Check for existence of global attribute when you get_attributes() for a product.
|
||||
* Fix - Show order by template on product search.
|
||||
* Fix - Search variation skus in backend search.
|
||||
|
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
/**
|
||||
* Admin failed order email
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/emails/admin-failed-order.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; // Exit if accessed directly ?>
|
||||
|
||||
<?php do_action( 'woocommerce_email_header', $email_heading, $email ); ?>
|
||||
|
||||
<p><?php printf( __( 'Payment for order #%d from %s has failed. The order was as follows:', 'woocommerce' ), $order->get_order_number(), $order->get_formatted_billing_full_name() ); ?></p>
|
||||
|
||||
<?php do_action( 'woocommerce_email_before_order_table', $order, true, false ); ?>
|
||||
|
||||
<h2><a class="link" href="<?php echo admin_url( 'post.php?post=' . $order->id . '&action=edit' ); ?>"><?php printf( __( 'Order: %s', 'woocommerce'), $order->get_order_number() ); ?></a> (<?php printf( '<time datetime="%s">%s</time>', date_i18n( 'c', strtotime( $order->order_date ) ), date_i18n( wc_date_format(), strtotime( $order->order_date ) ) ); ?>)</h2>
|
||||
|
||||
<table class="td" cellspacing="0" cellpadding="6" style="width: 100%; font-family: 'Helvetica Neue', Helvetica, Roboto, Arial, sans-serif;" border="1">
|
||||
<thead>
|
||||
<tr>
|
||||
<th class="td" scope="col" style="text-align:left;"><?php _e( 'Product', 'woocommerce' ); ?></th>
|
||||
<th class="td" scope="col" style="text-align:left;"><?php _e( 'Quantity', 'woocommerce' ); ?></th>
|
||||
<th class="td" scope="col" style="text-align:left;"><?php _e( 'Price', 'woocommerce' ); ?></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php echo $order->email_order_items_table( false, true ); ?>
|
||||
</tbody>
|
||||
<tfoot>
|
||||
<?php
|
||||
if ( $totals = $order->get_order_item_totals() ) {
|
||||
$i = 0;
|
||||
foreach ( $totals as $total ) {
|
||||
$i++;
|
||||
?><tr>
|
||||
<th class="td" scope="row" colspan="2" style="text-align:left; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['label']; ?></th>
|
||||
<td class="td" style="text-align:left; <?php if ( $i == 1 ) echo 'border-top-width: 4px;'; ?>"><?php echo $total['value']; ?></td>
|
||||
</tr><?php
|
||||
}
|
||||
}
|
||||
?>
|
||||
</tfoot>
|
||||
</table>
|
||||
|
||||
<?php do_action( 'woocommerce_email_after_order_table', $order, true, false, $email ); ?>
|
||||
|
||||
<?php do_action( 'woocommerce_email_order_meta', $order, true, false, $email ); ?>
|
||||
|
||||
<?php do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email ); ?>
|
||||
|
||||
<?php do_action( 'woocommerce_email_footer', $email ); ?>
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
/**
|
||||
* Admin failed order email (plain text)
|
||||
*
|
||||
* This template can be overridden by copying it to yourtheme/woocommerce/emails/plain/admin-failed-order.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.3.0
|
||||
*/
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly
|
||||
}
|
||||
|
||||
echo "= " . $email_heading . " =\n\n";
|
||||
|
||||
echo sprintf( __( 'Payment for order #%d from %s has failed. The order was as follows:', 'woocommerce' ), $order->id, $order->get_formatted_billing_full_name() ) . "\n\n";
|
||||
|
||||
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
|
||||
|
||||
do_action( 'woocommerce_email_before_order_table', $order, $sent_to_admin, $plain_text, $email );
|
||||
|
||||
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, $email );
|
||||
|
||||
echo "\n" . $order->email_order_items_table( false, true, '', '', '', true );
|
||||
|
||||
echo "==========\n\n";
|
||||
|
||||
if ( $totals = $order->get_order_item_totals() ) {
|
||||
foreach ( $totals as $total ) {
|
||||
echo $total['label'] . "\t " . $total['value'] . "\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, $email );
|
||||
|
||||
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );
|
||||
|
||||
echo "\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=\n\n";
|
||||
|
||||
echo apply_filters( 'woocommerce_email_footer_text', get_option( 'woocommerce_email_footer_text' ) );
|
Loading…
Reference in New Issue