initial commit
This commit is contained in:
209
includes/emails/class-wc-email-cancelled-order.php
Normal file
209
includes/emails/class-wc-email-cancelled-order.php
Normal file
@ -0,0 +1,209 @@
|
||||
<?php
|
||||
/**
|
||||
* Class WC_Email_Cancelled_Order file.
|
||||
*
|
||||
* @package WooCommerce\Emails
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_Cancelled_Order', false ) ) :
|
||||
|
||||
/**
|
||||
* Cancelled Order Email.
|
||||
*
|
||||
* An email sent to the admin when an order is cancelled.
|
||||
*
|
||||
* @class WC_Email_Cancelled_Order
|
||||
* @version 2.2.7
|
||||
* @package WooCommerce\Classes\Emails
|
||||
* @extends WC_Email
|
||||
*/
|
||||
class WC_Email_Cancelled_Order extends WC_Email {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->id = 'cancelled_order';
|
||||
$this->title = __( 'Cancelled order', 'woocommerce' );
|
||||
$this->description = __( 'Cancelled order emails are sent to chosen recipient(s) when orders have been marked cancelled (if they were previously processing or on-hold).', 'woocommerce' );
|
||||
$this->template_html = 'emails/admin-cancelled-order.php';
|
||||
$this->template_plain = 'emails/plain/admin-cancelled-order.php';
|
||||
$this->placeholders = array(
|
||||
'{order_date}' => '',
|
||||
'{order_number}' => '',
|
||||
'{order_billing_full_name}' => '',
|
||||
);
|
||||
|
||||
// Triggers for this email.
|
||||
add_action( 'woocommerce_order_status_processing_to_cancelled_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_on-hold_to_cancelled_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
|
||||
// Call parent constructor.
|
||||
parent::__construct();
|
||||
|
||||
// Other settings.
|
||||
$this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_subject() {
|
||||
return __( '[{site_title}]: Order #{order_number} has been cancelled', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_heading() {
|
||||
return __( 'Order Cancelled: #{order_number}', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the sending of this email.
|
||||
*
|
||||
* @param int $order_id The order ID.
|
||||
* @param WC_Order|false $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
||||
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->placeholders['{order_billing_full_name}'] = $this->object->get_formatted_billing_full_name();
|
||||
}
|
||||
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content html.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_html() {
|
||||
return wc_get_template_html(
|
||||
$this->template_html,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => true,
|
||||
'plain_text' => false,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content plain.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_plain() {
|
||||
return wc_get_template_html(
|
||||
$this->template_plain,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => true,
|
||||
'plain_text' => true,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default content to show below main email content.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_additional_content() {
|
||||
return __( 'Thanks for reading.', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise settings form fields.
|
||||
*/
|
||||
public function init_form_fields() {
|
||||
/* translators: %s: list of placeholders */
|
||||
$placeholder_text = sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '<code>' . esc_html( implode( '</code>, <code>', array_keys( $this->placeholders ) ) ) . '</code>' );
|
||||
$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',
|
||||
/* translators: %s: admin email */
|
||||
'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'woocommerce' ), '<code>' . esc_attr( get_option( 'admin_email' ) ) . '</code>' ),
|
||||
'placeholder' => '',
|
||||
'default' => '',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
'subject' => array(
|
||||
'title' => __( 'Subject', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_subject(),
|
||||
'default' => '',
|
||||
),
|
||||
'heading' => array(
|
||||
'title' => __( 'Email heading', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_heading(),
|
||||
'default' => '',
|
||||
),
|
||||
'additional_content' => array(
|
||||
'title' => __( 'Additional content', 'woocommerce' ),
|
||||
'description' => __( 'Text to appear below the main email content.', 'woocommerce' ) . ' ' . $placeholder_text,
|
||||
'css' => 'width:400px; height: 75px;',
|
||||
'placeholder' => __( 'N/A', 'woocommerce' ),
|
||||
'type' => 'textarea',
|
||||
'default' => $this->get_default_additional_content(),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
'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(),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new WC_Email_Cancelled_Order();
|
||||
146
includes/emails/class-wc-email-customer-completed-order.php
Normal file
146
includes/emails/class-wc-email-customer-completed-order.php
Normal file
@ -0,0 +1,146 @@
|
||||
<?php
|
||||
/**
|
||||
* Class WC_Email_Customer_Completed_Order file.
|
||||
*
|
||||
* @package WooCommerce\Emails
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_Customer_Completed_Order', false ) ) :
|
||||
|
||||
/**
|
||||
* Customer Completed Order Email.
|
||||
*
|
||||
* Order complete emails are sent to the customer when the order is marked complete and usual indicates that the order has been shipped.
|
||||
*
|
||||
* @class WC_Email_Customer_Completed_Order
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce\Classes\Emails
|
||||
* @extends WC_Email
|
||||
*/
|
||||
class WC_Email_Customer_Completed_Order extends WC_Email {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->id = 'customer_completed_order';
|
||||
$this->customer_email = true;
|
||||
$this->title = __( 'Completed order', 'woocommerce' );
|
||||
$this->description = __( 'Order complete emails are sent to customers when their orders are marked completed and usually indicate that their orders have been shipped.', 'woocommerce' );
|
||||
$this->template_html = 'emails/customer-completed-order.php';
|
||||
$this->template_plain = 'emails/plain/customer-completed-order.php';
|
||||
$this->placeholders = array(
|
||||
'{order_date}' => '',
|
||||
'{order_number}' => '',
|
||||
);
|
||||
|
||||
// Triggers for this email.
|
||||
add_action( 'woocommerce_order_status_completed_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
|
||||
// Call parent constructor.
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the sending of this email.
|
||||
*
|
||||
* @param int $order_id The order ID.
|
||||
* @param WC_Order|false $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
||||
if ( is_a( $order, 'WC_Order' ) ) {
|
||||
$this->object = $order;
|
||||
$this->recipient = $this->object->get_billing_email();
|
||||
$this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
|
||||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_subject() {
|
||||
return __( 'Your {site_title} order is now complete', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_heading() {
|
||||
return __( 'Thanks for shopping with us', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content html.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_html() {
|
||||
return wc_get_template_html(
|
||||
$this->template_html,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => false,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content plain.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_plain() {
|
||||
return wc_get_template_html(
|
||||
$this->template_plain,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => true,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default content to show below main email content.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_additional_content() {
|
||||
return __( 'Thanks for shopping with us.', 'woocommerce' );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new WC_Email_Customer_Completed_Order();
|
||||
246
includes/emails/class-wc-email-customer-invoice.php
Normal file
246
includes/emails/class-wc-email-customer-invoice.php
Normal file
@ -0,0 +1,246 @@
|
||||
<?php
|
||||
/**
|
||||
* Class WC_Email_Customer_Invoice file.
|
||||
*
|
||||
* @package WooCommerce\Emails
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_Customer_Invoice', false ) ) :
|
||||
|
||||
/**
|
||||
* Customer Invoice.
|
||||
*
|
||||
* An email sent to the customer via admin.
|
||||
*
|
||||
* @class WC_Email_Customer_Invoice
|
||||
* @version 3.5.0
|
||||
* @package WooCommerce\Classes\Emails
|
||||
* @extends WC_Email
|
||||
*/
|
||||
class WC_Email_Customer_Invoice extends WC_Email {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->id = 'customer_invoice';
|
||||
$this->customer_email = true;
|
||||
$this->title = __( 'Customer invoice / Order details', 'woocommerce' );
|
||||
$this->description = __( 'Customer invoice emails can be sent to customers containing their order information and payment links.', 'woocommerce' );
|
||||
$this->template_html = 'emails/customer-invoice.php';
|
||||
$this->template_plain = 'emails/plain/customer-invoice.php';
|
||||
$this->placeholders = array(
|
||||
'{order_date}' => '',
|
||||
'{order_number}' => '',
|
||||
);
|
||||
|
||||
// Call parent constructor.
|
||||
parent::__construct();
|
||||
|
||||
$this->manual = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @param bool $paid Whether the order has been paid or not.
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_subject( $paid = false ) {
|
||||
if ( $paid ) {
|
||||
return __( 'Invoice for order #{order_number} on {site_title}', 'woocommerce' );
|
||||
} else {
|
||||
return __( 'Your latest {site_title} invoice', 'woocommerce' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @param bool $paid Whether the order has been paid or not.
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_heading( $paid = false ) {
|
||||
if ( $paid ) {
|
||||
return __( 'Invoice for order #{order_number}', 'woocommerce' );
|
||||
} else {
|
||||
return __( 'Your invoice for order #{order_number}', 'woocommerce' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_subject() {
|
||||
if ( $this->object->has_status( array( 'completed', 'processing' ) ) ) {
|
||||
$subject = $this->get_option( 'subject_paid', $this->get_default_subject( true ) );
|
||||
|
||||
return apply_filters( 'woocommerce_email_subject_customer_invoice_paid', $this->format_string( $subject ), $this->object, $this );
|
||||
}
|
||||
|
||||
$subject = $this->get_option( 'subject', $this->get_default_subject() );
|
||||
return apply_filters( 'woocommerce_email_subject_customer_invoice', $this->format_string( $subject ), $this->object, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_heading() {
|
||||
if ( $this->object->has_status( wc_get_is_paid_statuses() ) ) {
|
||||
$heading = $this->get_option( 'heading_paid', $this->get_default_heading( true ) );
|
||||
return apply_filters( 'woocommerce_email_heading_customer_invoice_paid', $this->format_string( $heading ), $this->object, $this );
|
||||
}
|
||||
|
||||
$heading = $this->get_option( 'heading', $this->get_default_heading() );
|
||||
return apply_filters( 'woocommerce_email_heading_customer_invoice', $this->format_string( $heading ), $this->object, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Default content to show below main email content.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_additional_content() {
|
||||
return __( 'Thanks for using {site_url}!', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the sending of this email.
|
||||
*
|
||||
* @param int $order_id The order ID.
|
||||
* @param WC_Order $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
||||
if ( is_a( $order, 'WC_Order' ) ) {
|
||||
$this->object = $order;
|
||||
$this->recipient = $this->object->get_billing_email();
|
||||
$this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
|
||||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content html.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_html() {
|
||||
return wc_get_template_html(
|
||||
$this->template_html,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => false,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content plain.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_plain() {
|
||||
return wc_get_template_html(
|
||||
$this->template_plain,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => true,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise settings form fields.
|
||||
*/
|
||||
public function init_form_fields() {
|
||||
/* translators: %s: list of placeholders */
|
||||
$placeholder_text = sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '<code>' . esc_html( implode( '</code>, <code>', array_keys( $this->placeholders ) ) ) . '</code>' );
|
||||
$this->form_fields = array(
|
||||
'subject' => array(
|
||||
'title' => __( 'Subject', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_subject(),
|
||||
'default' => '',
|
||||
),
|
||||
'heading' => array(
|
||||
'title' => __( 'Email heading', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_heading(),
|
||||
'default' => '',
|
||||
),
|
||||
'subject_paid' => array(
|
||||
'title' => __( 'Subject (paid)', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_subject( true ),
|
||||
'default' => '',
|
||||
),
|
||||
'heading_paid' => array(
|
||||
'title' => __( 'Email heading (paid)', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_heading( true ),
|
||||
'default' => '',
|
||||
),
|
||||
'additional_content' => array(
|
||||
'title' => __( 'Additional content', 'woocommerce' ),
|
||||
'description' => __( 'Text to appear below the main email content.', 'woocommerce' ) . ' ' . $placeholder_text,
|
||||
'css' => 'width:400px; height: 75px;',
|
||||
'placeholder' => __( 'N/A', 'woocommerce' ),
|
||||
'type' => 'textarea',
|
||||
'default' => $this->get_default_additional_content(),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
'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(),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new WC_Email_Customer_Invoice();
|
||||
173
includes/emails/class-wc-email-customer-new-account.php
Normal file
173
includes/emails/class-wc-email-customer-new-account.php
Normal file
@ -0,0 +1,173 @@
|
||||
<?php
|
||||
/**
|
||||
* Class WC_Email_Customer_New_Account file.
|
||||
*
|
||||
* @package WooCommerce\Emails
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_Customer_New_Account', false ) ) :
|
||||
|
||||
/**
|
||||
* Customer New Account.
|
||||
*
|
||||
* An email sent to the customer when they create an account.
|
||||
*
|
||||
* @class WC_Email_Customer_New_Account
|
||||
* @version 3.5.0
|
||||
* @package WooCommerce\Classes\Emails
|
||||
* @extends WC_Email
|
||||
*/
|
||||
class WC_Email_Customer_New_Account extends WC_Email {
|
||||
|
||||
/**
|
||||
* User login name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $user_login;
|
||||
|
||||
/**
|
||||
* User email.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $user_email;
|
||||
|
||||
/**
|
||||
* User password.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $user_pass;
|
||||
|
||||
/**
|
||||
* Is the password generated?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $password_generated;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->id = 'customer_new_account';
|
||||
$this->customer_email = true;
|
||||
$this->title = __( 'New account', 'woocommerce' );
|
||||
$this->description = __( 'Customer "new account" emails are sent to the customer when a customer signs up via checkout or account pages.', 'woocommerce' );
|
||||
$this->template_html = 'emails/customer-new-account.php';
|
||||
$this->template_plain = 'emails/plain/customer-new-account.php';
|
||||
|
||||
// Call parent constructor.
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_subject() {
|
||||
return __( 'Your {site_title} account has been created!', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_heading() {
|
||||
return __( 'Welcome to {site_title}', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger.
|
||||
*
|
||||
* @param int $user_id User ID.
|
||||
* @param string $user_pass User password.
|
||||
* @param bool $password_generated Whether the password was generated automatically or not.
|
||||
*/
|
||||
public function trigger( $user_id, $user_pass = '', $password_generated = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $user_id ) {
|
||||
$this->object = new WP_User( $user_id );
|
||||
|
||||
$this->user_pass = $user_pass;
|
||||
$this->user_login = stripslashes( $this->object->user_login );
|
||||
$this->user_email = stripslashes( $this->object->user_email );
|
||||
$this->recipient = $this->user_email;
|
||||
$this->password_generated = $password_generated;
|
||||
}
|
||||
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content html.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_html() {
|
||||
return wc_get_template_html(
|
||||
$this->template_html,
|
||||
array(
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'user_login' => $this->user_login,
|
||||
'user_pass' => $this->user_pass,
|
||||
'blogname' => $this->get_blogname(),
|
||||
'password_generated' => $this->password_generated,
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => false,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content plain.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_plain() {
|
||||
return wc_get_template_html(
|
||||
$this->template_plain,
|
||||
array(
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'user_login' => $this->user_login,
|
||||
'user_pass' => $this->user_pass,
|
||||
'blogname' => $this->get_blogname(),
|
||||
'password_generated' => $this->password_generated,
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => true,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default content to show below main email content.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_additional_content() {
|
||||
return __( 'We look forward to seeing you soon.', 'woocommerce' );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new WC_Email_Customer_New_Account();
|
||||
166
includes/emails/class-wc-email-customer-note.php
Normal file
166
includes/emails/class-wc-email-customer-note.php
Normal file
@ -0,0 +1,166 @@
|
||||
<?php
|
||||
/**
|
||||
* Class WC_Email_Customer_Note file.
|
||||
*
|
||||
* @package WooCommerce\Emails
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_Customer_Note', false ) ) :
|
||||
|
||||
/**
|
||||
* Customer Note Order Email.
|
||||
*
|
||||
* Customer note emails are sent when you add a note to an order.
|
||||
*
|
||||
* @class WC_Email_Customer_Note
|
||||
* @version 3.5.0
|
||||
* @package WooCommerce\Classes\Emails
|
||||
* @extends WC_Email
|
||||
*/
|
||||
class WC_Email_Customer_Note extends WC_Email {
|
||||
|
||||
/**
|
||||
* Customer note.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $customer_note;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->id = 'customer_note';
|
||||
$this->customer_email = true;
|
||||
$this->title = __( 'Customer note', 'woocommerce' );
|
||||
$this->description = __( 'Customer note emails are sent when you add a note to an order.', 'woocommerce' );
|
||||
$this->template_html = 'emails/customer-note.php';
|
||||
$this->template_plain = 'emails/plain/customer-note.php';
|
||||
$this->placeholders = array(
|
||||
'{order_date}' => '',
|
||||
'{order_number}' => '',
|
||||
);
|
||||
|
||||
// Triggers.
|
||||
add_action( 'woocommerce_new_customer_note_notification', array( $this, 'trigger' ) );
|
||||
|
||||
// Call parent constructor.
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_subject() {
|
||||
return __( 'Note added to your {site_title} order from {order_date}', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_heading() {
|
||||
return __( 'A note has been added to your order', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger.
|
||||
*
|
||||
* @param array $args Email arguments.
|
||||
*/
|
||||
public function trigger( $args ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( ! empty( $args ) ) {
|
||||
$defaults = array(
|
||||
'order_id' => '',
|
||||
'customer_note' => '',
|
||||
);
|
||||
|
||||
$args = wp_parse_args( $args, $defaults );
|
||||
|
||||
$order_id = $args['order_id'];
|
||||
$customer_note = $args['customer_note'];
|
||||
|
||||
if ( $order_id ) {
|
||||
$this->object = wc_get_order( $order_id );
|
||||
|
||||
if ( $this->object ) {
|
||||
$this->recipient = $this->object->get_billing_email();
|
||||
$this->customer_note = $customer_note;
|
||||
$this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
|
||||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content html.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_html() {
|
||||
return wc_get_template_html(
|
||||
$this->template_html,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'customer_note' => $this->customer_note,
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => false,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content plain.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_plain() {
|
||||
return wc_get_template_html(
|
||||
$this->template_plain,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'customer_note' => $this->customer_note,
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => true,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default content to show below main email content.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_additional_content() {
|
||||
return __( 'Thanks for reading.', 'woocommerce' );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new WC_Email_Customer_Note();
|
||||
148
includes/emails/class-wc-email-customer-on-hold-order.php
Normal file
148
includes/emails/class-wc-email-customer-on-hold-order.php
Normal file
@ -0,0 +1,148 @@
|
||||
<?php
|
||||
/**
|
||||
* Class WC_Email_Customer_On_Hold_Order file.
|
||||
*
|
||||
* @package WooCommerce\Emails
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_Customer_On_Hold_Order', false ) ) :
|
||||
|
||||
/**
|
||||
* Customer On-hold Order Email.
|
||||
*
|
||||
* An email sent to the customer when a new order is on-hold for.
|
||||
*
|
||||
* @class WC_Email_Customer_On_Hold_Order
|
||||
* @version 2.6.0
|
||||
* @package WooCommerce\Classes\Emails
|
||||
* @extends WC_Email
|
||||
*/
|
||||
class WC_Email_Customer_On_Hold_Order extends WC_Email {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->id = 'customer_on_hold_order';
|
||||
$this->customer_email = true;
|
||||
$this->title = __( 'Order on-hold', 'woocommerce' );
|
||||
$this->description = __( 'This is an order notification sent to customers containing order details after an order is placed on-hold.', 'woocommerce' );
|
||||
$this->template_html = 'emails/customer-on-hold-order.php';
|
||||
$this->template_plain = 'emails/plain/customer-on-hold-order.php';
|
||||
$this->placeholders = array(
|
||||
'{order_date}' => '',
|
||||
'{order_number}' => '',
|
||||
);
|
||||
|
||||
// Triggers for this email.
|
||||
add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_cancelled_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
|
||||
// Call parent constructor.
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_subject() {
|
||||
return __( 'Your {site_title} order has been received!', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_heading() {
|
||||
return __( 'Thank you for your order', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the sending of this email.
|
||||
*
|
||||
* @param int $order_id The order ID.
|
||||
* @param WC_Order|false $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
||||
if ( is_a( $order, 'WC_Order' ) ) {
|
||||
$this->object = $order;
|
||||
$this->recipient = $this->object->get_billing_email();
|
||||
$this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
|
||||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content html.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_html() {
|
||||
return wc_get_template_html(
|
||||
$this->template_html,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => false,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content plain.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_plain() {
|
||||
return wc_get_template_html(
|
||||
$this->template_plain,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => true,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default content to show below main email content.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_additional_content() {
|
||||
return __( 'We look forward to fulfilling your order soon.', 'woocommerce' );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new WC_Email_Customer_On_Hold_Order();
|
||||
150
includes/emails/class-wc-email-customer-processing-order.php
Normal file
150
includes/emails/class-wc-email-customer-processing-order.php
Normal file
@ -0,0 +1,150 @@
|
||||
<?php
|
||||
/**
|
||||
* Class WC_Email_Customer_Processing_Order file.
|
||||
*
|
||||
* @package WooCommerce\Emails
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_Customer_Processing_Order', false ) ) :
|
||||
|
||||
/**
|
||||
* Customer Processing Order Email.
|
||||
*
|
||||
* An email sent to the customer when a new order is paid for.
|
||||
*
|
||||
* @class WC_Email_Customer_Processing_Order
|
||||
* @version 3.5.0
|
||||
* @package WooCommerce\Classes\Emails
|
||||
* @extends WC_Email
|
||||
*/
|
||||
class WC_Email_Customer_Processing_Order extends WC_Email {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->id = 'customer_processing_order';
|
||||
$this->customer_email = true;
|
||||
|
||||
$this->title = __( 'Processing order', 'woocommerce' );
|
||||
$this->description = __( 'This is an order notification sent to customers containing order details after payment.', 'woocommerce' );
|
||||
$this->template_html = 'emails/customer-processing-order.php';
|
||||
$this->template_plain = 'emails/plain/customer-processing-order.php';
|
||||
$this->placeholders = array(
|
||||
'{order_date}' => '',
|
||||
'{order_number}' => '',
|
||||
);
|
||||
|
||||
// Triggers for this email.
|
||||
add_action( 'woocommerce_order_status_cancelled_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_on-hold_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
|
||||
// Call parent constructor.
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_subject() {
|
||||
return __( 'Your {site_title} order has been received!', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_heading() {
|
||||
return __( 'Thank you for your order', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the sending of this email.
|
||||
*
|
||||
* @param int $order_id The order ID.
|
||||
* @param WC_Order|false $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
||||
if ( is_a( $order, 'WC_Order' ) ) {
|
||||
$this->object = $order;
|
||||
$this->recipient = $this->object->get_billing_email();
|
||||
$this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
|
||||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content html.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_html() {
|
||||
return wc_get_template_html(
|
||||
$this->template_html,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => false,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content plain.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_plain() {
|
||||
return wc_get_template_html(
|
||||
$this->template_plain,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => true,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default content to show below main email content.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_additional_content() {
|
||||
return __( 'Thanks for using {site_url}!', 'woocommerce' );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new WC_Email_Customer_Processing_Order();
|
||||
302
includes/emails/class-wc-email-customer-refunded-order.php
Normal file
302
includes/emails/class-wc-email-customer-refunded-order.php
Normal file
@ -0,0 +1,302 @@
|
||||
<?php
|
||||
/**
|
||||
* Class WC_Email_Customer_Refunded_Order file.
|
||||
*
|
||||
* @package WooCommerce\Emails
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_Customer_Refunded_Order', false ) ) :
|
||||
|
||||
/**
|
||||
* Customer Refunded Order Email.
|
||||
*
|
||||
* Order refunded emails are sent to the customer when the order is marked refunded.
|
||||
*
|
||||
* @class WC_Email_Customer_Refunded_Order
|
||||
* @version 3.5.0
|
||||
* @package WooCommerce\Classes\Emails
|
||||
* @extends WC_Email
|
||||
*/
|
||||
class WC_Email_Customer_Refunded_Order extends WC_Email {
|
||||
|
||||
/**
|
||||
* Refund order.
|
||||
*
|
||||
* @var WC_Order|bool
|
||||
*/
|
||||
public $refund;
|
||||
|
||||
/**
|
||||
* Is the order partial refunded?
|
||||
*
|
||||
* @var bool
|
||||
*/
|
||||
public $partial_refund;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->customer_email = true;
|
||||
$this->id = 'customer_refunded_order';
|
||||
$this->title = __( 'Refunded order', 'woocommerce' );
|
||||
$this->description = __( 'Order refunded emails are sent to customers when their orders are refunded.', 'woocommerce' );
|
||||
$this->template_html = 'emails/customer-refunded-order.php';
|
||||
$this->template_plain = 'emails/plain/customer-refunded-order.php';
|
||||
$this->placeholders = array(
|
||||
'{order_date}' => '',
|
||||
'{order_number}' => '',
|
||||
);
|
||||
|
||||
// Triggers for this email.
|
||||
add_action( 'woocommerce_order_fully_refunded_notification', array( $this, 'trigger_full' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_partially_refunded_notification', array( $this, 'trigger_partial' ), 10, 2 );
|
||||
|
||||
// Call parent constructor.
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @param bool $partial Whether it is a partial refund or a full refund.
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_subject( $partial = false ) {
|
||||
if ( $partial ) {
|
||||
return __( 'Your {site_title} order #{order_number} has been partially refunded', 'woocommerce' );
|
||||
} else {
|
||||
return __( 'Your {site_title} order #{order_number} has been refunded', 'woocommerce' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @param bool $partial Whether it is a partial refund or a full refund.
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_heading( $partial = false ) {
|
||||
if ( $partial ) {
|
||||
return __( 'Partial Refund: Order {order_number}', 'woocommerce' );
|
||||
} else {
|
||||
return __( 'Order Refunded: {order_number}', 'woocommerce' );
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_subject() {
|
||||
if ( $this->partial_refund ) {
|
||||
$subject = $this->get_option( 'subject_partial', $this->get_default_subject( true ) );
|
||||
} else {
|
||||
$subject = $this->get_option( 'subject_full', $this->get_default_subject() );
|
||||
}
|
||||
return apply_filters( 'woocommerce_email_subject_customer_refunded_order', $this->format_string( $subject ), $this->object, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_heading() {
|
||||
if ( $this->partial_refund ) {
|
||||
$heading = $this->get_option( 'heading_partial', $this->get_default_heading( true ) );
|
||||
} else {
|
||||
$heading = $this->get_option( 'heading_full', $this->get_default_heading() );
|
||||
}
|
||||
return apply_filters( 'woocommerce_email_heading_customer_refunded_order', $this->format_string( $heading ), $this->object, $this );
|
||||
}
|
||||
|
||||
/**
|
||||
* Set email strings.
|
||||
*
|
||||
* @param bool $partial_refund Whether it is a partial refund or a full refund.
|
||||
* @deprecated 3.1.0 Unused.
|
||||
*/
|
||||
public function set_email_strings( $partial_refund = false ) {}
|
||||
|
||||
/**
|
||||
* Full refund notification.
|
||||
*
|
||||
* @param int $order_id Order ID.
|
||||
* @param int $refund_id Refund ID.
|
||||
*/
|
||||
public function trigger_full( $order_id, $refund_id = null ) {
|
||||
$this->trigger( $order_id, false, $refund_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Partial refund notification.
|
||||
*
|
||||
* @param int $order_id Order ID.
|
||||
* @param int $refund_id Refund ID.
|
||||
*/
|
||||
public function trigger_partial( $order_id, $refund_id = null ) {
|
||||
$this->trigger( $order_id, true, $refund_id );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger.
|
||||
*
|
||||
* @param int $order_id Order ID.
|
||||
* @param bool $partial_refund Whether it is a partial refund or a full refund.
|
||||
* @param int $refund_id Refund ID.
|
||||
*/
|
||||
public function trigger( $order_id, $partial_refund = false, $refund_id = null ) {
|
||||
$this->setup_locale();
|
||||
$this->partial_refund = $partial_refund;
|
||||
$this->id = $this->partial_refund ? 'customer_partially_refunded_order' : 'customer_refunded_order';
|
||||
|
||||
if ( $order_id ) {
|
||||
$this->object = wc_get_order( $order_id );
|
||||
$this->recipient = $this->object->get_billing_email();
|
||||
$this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() );
|
||||
$this->placeholders['{order_number}'] = $this->object->get_order_number();
|
||||
}
|
||||
|
||||
if ( ! empty( $refund_id ) ) {
|
||||
$this->refund = wc_get_order( $refund_id );
|
||||
} else {
|
||||
$this->refund = false;
|
||||
}
|
||||
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content html.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_html() {
|
||||
return wc_get_template_html(
|
||||
$this->template_html,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'refund' => $this->refund,
|
||||
'partial_refund' => $this->partial_refund,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => false,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content plain.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_plain() {
|
||||
return wc_get_template_html(
|
||||
$this->template_plain,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'refund' => $this->refund,
|
||||
'partial_refund' => $this->partial_refund,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => true,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default content to show below main email content.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_additional_content() {
|
||||
return __( 'We hope to see you again soon.', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise settings form fields.
|
||||
*/
|
||||
public function init_form_fields() {
|
||||
/* translators: %s: list of placeholders */
|
||||
$placeholder_text = sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '<code>' . esc_html( implode( '</code>, <code>', array_keys( $this->placeholders ) ) ) . '</code>' );
|
||||
$this->form_fields = array(
|
||||
'enabled' => array(
|
||||
'title' => __( 'Enable/Disable', 'woocommerce' ),
|
||||
'type' => 'checkbox',
|
||||
'label' => __( 'Enable this email notification', 'woocommerce' ),
|
||||
'default' => 'yes',
|
||||
),
|
||||
'subject_full' => array(
|
||||
'title' => __( 'Full refund subject', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_subject(),
|
||||
'default' => '',
|
||||
),
|
||||
'subject_partial' => array(
|
||||
'title' => __( 'Partial refund subject', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_subject( true ),
|
||||
'default' => '',
|
||||
),
|
||||
'heading_full' => array(
|
||||
'title' => __( 'Full refund email heading', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_heading(),
|
||||
'default' => '',
|
||||
),
|
||||
'heading_partial' => array(
|
||||
'title' => __( 'Partial refund email heading', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_heading( true ),
|
||||
'default' => '',
|
||||
),
|
||||
'additional_content' => array(
|
||||
'title' => __( 'Additional content', 'woocommerce' ),
|
||||
'description' => __( 'Text to appear below the main email content.', 'woocommerce' ) . ' ' . $placeholder_text,
|
||||
'css' => 'width:400px; height: 75px;',
|
||||
'placeholder' => __( 'N/A', 'woocommerce' ),
|
||||
'type' => 'textarea',
|
||||
'default' => $this->get_default_additional_content(),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
'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(),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new WC_Email_Customer_Refunded_Order();
|
||||
177
includes/emails/class-wc-email-customer-reset-password.php
Normal file
177
includes/emails/class-wc-email-customer-reset-password.php
Normal file
@ -0,0 +1,177 @@
|
||||
<?php
|
||||
/**
|
||||
* Class WC_Email_Customer_Reset_Password file.
|
||||
*
|
||||
* @package WooCommerce\Emails
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit; // Exit if accessed directly.
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_Customer_Reset_Password', false ) ) :
|
||||
|
||||
/**
|
||||
* Customer Reset Password.
|
||||
*
|
||||
* An email sent to the customer when they reset their password.
|
||||
*
|
||||
* @class WC_Email_Customer_Reset_Password
|
||||
* @version 3.5.0
|
||||
* @package WooCommerce\Classes\Emails
|
||||
* @extends WC_Email
|
||||
*/
|
||||
class WC_Email_Customer_Reset_Password extends WC_Email {
|
||||
|
||||
/**
|
||||
* User ID.
|
||||
*
|
||||
* @var integer
|
||||
*/
|
||||
public $user_id;
|
||||
|
||||
/**
|
||||
* User login name.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $user_login;
|
||||
|
||||
/**
|
||||
* User email.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $user_email;
|
||||
|
||||
/**
|
||||
* Reset key.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
public $reset_key;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
|
||||
$this->id = 'customer_reset_password';
|
||||
$this->customer_email = true;
|
||||
|
||||
$this->title = __( 'Reset password', 'woocommerce' );
|
||||
$this->description = __( 'Customer "reset password" emails are sent when customers reset their passwords.', 'woocommerce' );
|
||||
|
||||
$this->template_html = 'emails/customer-reset-password.php';
|
||||
$this->template_plain = 'emails/plain/customer-reset-password.php';
|
||||
|
||||
// Trigger.
|
||||
add_action( 'woocommerce_reset_password_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
|
||||
// Call parent constructor.
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_subject() {
|
||||
return __( 'Password Reset Request for {site_title}', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_heading() {
|
||||
return __( 'Password Reset Request', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger.
|
||||
*
|
||||
* @param string $user_login User login.
|
||||
* @param string $reset_key Password reset key.
|
||||
*/
|
||||
public function trigger( $user_login = '', $reset_key = '' ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $user_login && $reset_key ) {
|
||||
$this->object = get_user_by( 'login', $user_login );
|
||||
$this->user_id = $this->object->ID;
|
||||
$this->user_login = $user_login;
|
||||
$this->reset_key = $reset_key;
|
||||
$this->user_email = stripslashes( $this->object->user_email );
|
||||
$this->recipient = $this->user_email;
|
||||
}
|
||||
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content html.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_html() {
|
||||
return wc_get_template_html(
|
||||
$this->template_html,
|
||||
array(
|
||||
'email_heading' => $this->get_heading(),
|
||||
'user_id' => $this->user_id,
|
||||
'user_login' => $this->user_login,
|
||||
'reset_key' => $this->reset_key,
|
||||
'blogname' => $this->get_blogname(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => false,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content plain.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_plain() {
|
||||
return wc_get_template_html(
|
||||
$this->template_plain,
|
||||
array(
|
||||
'email_heading' => $this->get_heading(),
|
||||
'user_id' => $this->user_id,
|
||||
'user_login' => $this->user_login,
|
||||
'reset_key' => $this->reset_key,
|
||||
'blogname' => $this->get_blogname(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => false,
|
||||
'plain_text' => true,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default content to show below main email content.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_additional_content() {
|
||||
return __( 'Thanks for reading.', 'woocommerce' );
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new WC_Email_Customer_Reset_Password();
|
||||
207
includes/emails/class-wc-email-failed-order.php
Normal file
207
includes/emails/class-wc-email-failed-order.php
Normal file
@ -0,0 +1,207 @@
|
||||
<?php
|
||||
/**
|
||||
* Class WC_Email_Failed_Order file.
|
||||
*
|
||||
* @package WooCommerce\Emails
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_Failed_Order', false ) ) :
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @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 chosen recipient(s) when orders have been marked failed (if they were previously pending or on-hold).', 'woocommerce' );
|
||||
$this->template_html = 'emails/admin-failed-order.php';
|
||||
$this->template_plain = 'emails/plain/admin-failed-order.php';
|
||||
$this->placeholders = array(
|
||||
'{order_date}' => '',
|
||||
'{order_number}' => '',
|
||||
);
|
||||
|
||||
// Triggers for this email.
|
||||
add_action( 'woocommerce_order_status_pending_to_failed_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_on-hold_to_failed_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
|
||||
// Call parent constructor.
|
||||
parent::__construct();
|
||||
|
||||
// Other settings.
|
||||
$this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_subject() {
|
||||
return __( '[{site_title}]: Order #{order_number} has failed', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_heading() {
|
||||
return __( 'Order Failed: #{order_number}', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the sending of this email.
|
||||
*
|
||||
* @param int $order_id The order ID.
|
||||
* @param WC_Order|false $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
}
|
||||
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content html.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_html() {
|
||||
return wc_get_template_html(
|
||||
$this->template_html,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => true,
|
||||
'plain_text' => false,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content plain.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_plain() {
|
||||
return wc_get_template_html(
|
||||
$this->template_plain,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => true,
|
||||
'plain_text' => true,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default content to show below main email content.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_additional_content() {
|
||||
return __( 'Hopefully they’ll be back. Read more about <a href="https://docs.woocommerce.com/document/managing-orders/">troubleshooting failed payments</a>.', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise settings form fields.
|
||||
*/
|
||||
public function init_form_fields() {
|
||||
/* translators: %s: list of placeholders */
|
||||
$placeholder_text = sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '<code>' . esc_html( implode( '</code>, <code>', array_keys( $this->placeholders ) ) ) . '</code>' );
|
||||
$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',
|
||||
/* translators: %s: WP admin email */
|
||||
'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'woocommerce' ), '<code>' . esc_attr( get_option( 'admin_email' ) ) . '</code>' ),
|
||||
'placeholder' => '',
|
||||
'default' => '',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
'subject' => array(
|
||||
'title' => __( 'Subject', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_subject(),
|
||||
'default' => '',
|
||||
),
|
||||
'heading' => array(
|
||||
'title' => __( 'Email heading', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_heading(),
|
||||
'default' => '',
|
||||
),
|
||||
'additional_content' => array(
|
||||
'title' => __( 'Additional content', 'woocommerce' ),
|
||||
'description' => __( 'Text to appear below the main email content.', 'woocommerce' ) . ' ' . $placeholder_text,
|
||||
'css' => 'width:400px; height: 75px;',
|
||||
'placeholder' => __( 'N/A', 'woocommerce' ),
|
||||
'type' => 'textarea',
|
||||
'default' => $this->get_default_additional_content(),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
'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(),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new WC_Email_Failed_Order();
|
||||
229
includes/emails/class-wc-email-new-order.php
Normal file
229
includes/emails/class-wc-email-new-order.php
Normal file
@ -0,0 +1,229 @@
|
||||
<?php
|
||||
/**
|
||||
* Class WC_Email_New_Order file
|
||||
*
|
||||
* @package WooCommerce\Emails
|
||||
*/
|
||||
|
||||
if ( ! defined( 'ABSPATH' ) ) {
|
||||
exit;
|
||||
}
|
||||
|
||||
if ( ! class_exists( 'WC_Email_New_Order' ) ) :
|
||||
|
||||
/**
|
||||
* New Order Email.
|
||||
*
|
||||
* An email sent to the admin when a new order is received/paid for.
|
||||
*
|
||||
* @class WC_Email_New_Order
|
||||
* @version 2.0.0
|
||||
* @package WooCommerce\Classes\Emails
|
||||
* @extends WC_Email
|
||||
*/
|
||||
class WC_Email_New_Order extends WC_Email {
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*/
|
||||
public function __construct() {
|
||||
$this->id = 'new_order';
|
||||
$this->title = __( 'New order', 'woocommerce' );
|
||||
$this->description = __( 'New order emails are sent to chosen recipient(s) when a new order is received.', 'woocommerce' );
|
||||
$this->template_html = 'emails/admin-new-order.php';
|
||||
$this->template_plain = 'emails/plain/admin-new-order.php';
|
||||
$this->placeholders = array(
|
||||
'{order_date}' => '',
|
||||
'{order_number}' => '',
|
||||
);
|
||||
|
||||
// Triggers for this email.
|
||||
add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_pending_to_completed_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_failed_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_failed_to_completed_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_failed_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_cancelled_to_processing_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_cancelled_to_completed_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
add_action( 'woocommerce_order_status_cancelled_to_on-hold_notification', array( $this, 'trigger' ), 10, 2 );
|
||||
|
||||
// Call parent constructor.
|
||||
parent::__construct();
|
||||
|
||||
// Other settings.
|
||||
$this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email subject.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_subject() {
|
||||
return __( '[{site_title}]: New order #{order_number}', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get email heading.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_heading() {
|
||||
return __( 'New Order: #{order_number}', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Trigger the sending of this email.
|
||||
*
|
||||
* @param int $order_id The order ID.
|
||||
* @param WC_Order|false $order Order object.
|
||||
*/
|
||||
public function trigger( $order_id, $order = false ) {
|
||||
$this->setup_locale();
|
||||
|
||||
if ( $order_id && ! is_a( $order, 'WC_Order' ) ) {
|
||||
$order = wc_get_order( $order_id );
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
$email_already_sent = $order->get_meta( '_new_order_email_sent' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Controls if new order emails can be resend multiple times.
|
||||
*
|
||||
* @since 5.0.0
|
||||
* @param bool $allows Defaults to false.
|
||||
*/
|
||||
if ( 'true' === $email_already_sent && ! apply_filters( 'woocommerce_new_order_email_allows_resend', false ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
if ( $this->is_enabled() && $this->get_recipient() ) {
|
||||
$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
|
||||
|
||||
$order->update_meta_data( '_new_order_email_sent', 'true' );
|
||||
$order->save();
|
||||
}
|
||||
|
||||
$this->restore_locale();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content html.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_html() {
|
||||
return wc_get_template_html(
|
||||
$this->template_html,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => true,
|
||||
'plain_text' => false,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content plain.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_content_plain() {
|
||||
return wc_get_template_html(
|
||||
$this->template_plain,
|
||||
array(
|
||||
'order' => $this->object,
|
||||
'email_heading' => $this->get_heading(),
|
||||
'additional_content' => $this->get_additional_content(),
|
||||
'sent_to_admin' => true,
|
||||
'plain_text' => true,
|
||||
'email' => $this,
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Default content to show below main email content.
|
||||
*
|
||||
* @since 3.7.0
|
||||
* @return string
|
||||
*/
|
||||
public function get_default_additional_content() {
|
||||
return __( 'Congratulations on the sale.', 'woocommerce' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialise settings form fields.
|
||||
*/
|
||||
public function init_form_fields() {
|
||||
/* translators: %s: list of placeholders */
|
||||
$placeholder_text = sprintf( __( 'Available placeholders: %s', 'woocommerce' ), '<code>' . implode( '</code>, <code>', array_keys( $this->placeholders ) ) . '</code>' );
|
||||
$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',
|
||||
/* translators: %s: WP admin email */
|
||||
'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'woocommerce' ), '<code>' . esc_attr( get_option( 'admin_email' ) ) . '</code>' ),
|
||||
'placeholder' => '',
|
||||
'default' => '',
|
||||
'desc_tip' => true,
|
||||
),
|
||||
'subject' => array(
|
||||
'title' => __( 'Subject', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_subject(),
|
||||
'default' => '',
|
||||
),
|
||||
'heading' => array(
|
||||
'title' => __( 'Email heading', 'woocommerce' ),
|
||||
'type' => 'text',
|
||||
'desc_tip' => true,
|
||||
'description' => $placeholder_text,
|
||||
'placeholder' => $this->get_default_heading(),
|
||||
'default' => '',
|
||||
),
|
||||
'additional_content' => array(
|
||||
'title' => __( 'Additional content', 'woocommerce' ),
|
||||
'description' => __( 'Text to appear below the main email content.', 'woocommerce' ) . ' ' . $placeholder_text,
|
||||
'css' => 'width:400px; height: 75px;',
|
||||
'placeholder' => __( 'N/A', 'woocommerce' ),
|
||||
'type' => 'textarea',
|
||||
'default' => $this->get_default_additional_content(),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
'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(),
|
||||
'desc_tip' => true,
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
endif;
|
||||
|
||||
return new WC_Email_New_Order();
|
||||
1092
includes/emails/class-wc-email.php
Normal file
1092
includes/emails/class-wc-email.php
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user