Code Duplication    Length = 94-94 lines in 2 locations

includes/emails/class-wc-email-customer-on-hold-order.php 1 location

@@ 7-100 (lines=94) @@
4
	exit; // Exit if accessed directly
5
}
6
7
if ( ! class_exists( 'WC_Email_Customer_Processing_Order' ) ) :
8
9
/**
10
 * Customer On-hold Order Email.
11
 *
12
 * An email sent to the customer when a new order is on-hold for.
13
 *
14
 * @class       WC_Email_Customer_On_Hold_Order
15
 * @version     2.6.0
16
 * @package     WooCommerce/Classes/Emails
17
 * @author      WooThemes
18
 * @extends     WC_Email
19
 */
20
class WC_Email_Customer_On_Hold_Order extends WC_Email {
21
22
	/**
23
	 * Constructor.
24
	 */
25
	public function __construct() {
26
		$this->id               = 'customer_on_hold_order';
27
		$this->customer_email   = true;
28
		$this->title            = __( 'Order on-hold', 'woocommerce' );
29
		$this->description      = __( 'This is an order notification sent to customers containing order details after an order is placed on-hold.', 'woocommerce' );
30
		$this->heading          = __( 'Thank you for your order', 'woocommerce' );
31
		$this->subject          = __( 'Your {site_title} order receipt from {order_date}', 'woocommerce' );
32
		$this->template_html    = 'emails/customer-on-hold-order.php';
33
		$this->template_plain   = 'emails/plain/customer-on-hold-order.php';
34
35
		// Triggers for this email
36
		add_action( 'woocommerce_order_status_pending_to_on-hold_notification', array( $this, 'trigger' ) );
37
38
		// Call parent constructor
39
		parent::__construct();
40
	}
41
42
	/**
43
	 * Trigger.
44
	 *
45
	 * @param int $order_id
46
	 */
47
	public function trigger( $order_id ) {
48
49
		if ( $order_id ) {
50
			$this->object       = wc_get_order( $order_id );
51
			$this->recipient    = $this->object->billing_email;
52
53
			$this->find['order-date']      = '{order_date}';
54
			$this->find['order-number']    = '{order_number}';
55
56
			$this->replace['order-date']   = date_i18n( wc_date_format(), strtotime( $this->object->order_date ) );
57
			$this->replace['order-number'] = $this->object->get_order_number();
58
		}
59
60
		if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
61
			return;
62
		}
63
64
		$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
65
	}
66
67
	/**
68
	 * Get content html.
69
	 *
70
	 * @access public
71
	 * @return string
72
	 */
73
	public function get_content_html() {
74
		return wc_get_template_html( $this->template_html, array(
75
			'order'         => $this->object,
76
			'email_heading' => $this->get_heading(),
77
			'sent_to_admin' => false,
78
			'plain_text'    => false,
79
			'email'			=> $this
80
		) );
81
	}
82
83
	/**
84
	 * Get content plain.
85
	 *
86
	 * @access public
87
	 * @return string
88
	 */
89
	public function get_content_plain() {
90
		return wc_get_template_html( $this->template_plain, array(
91
			'order'         => $this->object,
92
			'email_heading' => $this->get_heading(),
93
			'sent_to_admin' => false,
94
			'plain_text'    => true,
95
			'email'			=> $this
96
		) );
97
	}
98
}
99
100
endif;
101
102
return new WC_Email_Customer_On_Hold_Order();
103

includes/emails/class-wc-email-customer-processing-order.php 1 location

@@ 7-100 (lines=94) @@
4
	exit; // Exit if accessed directly
5
}
6
7
if ( ! class_exists( 'WC_Email_Customer_Processing_Order' ) ) :
8
9
/**
10
 * Customer Processing Order Email.
11
 *
12
 * An email sent to the customer when a new order is paid for.
13
 *
14
 * @class       WC_Email_Customer_Processing_Order
15
 * @version     2.0.0
16
 * @package     WooCommerce/Classes/Emails
17
 * @author      WooThemes
18
 * @extends     WC_Email
19
 */
20
class WC_Email_Customer_Processing_Order extends WC_Email {
21
22
	/**
23
	 * Constructor.
24
	 */
25
	public function __construct() {
26
		$this->id               = 'customer_processing_order';
27
		$this->customer_email   = true;
28
		$this->title            = __( 'Processing order', 'woocommerce' );
29
		$this->description      = __( 'This is an order notification sent to customers containing order details after payment.', 'woocommerce' );
30
		$this->heading          = __( 'Thank you for your order', 'woocommerce' );
31
		$this->subject          = __( 'Your {site_title} order receipt from {order_date}', 'woocommerce' );
32
		$this->template_html    = 'emails/customer-processing-order.php';
33
		$this->template_plain   = 'emails/plain/customer-processing-order.php';
34
35
		// Triggers for this email
36
		add_action( 'woocommerce_order_status_pending_to_processing_notification', array( $this, 'trigger' ) );
37
38
		// Call parent constructor
39
		parent::__construct();
40
	}
41
42
	/**
43
	 * Trigger.
44
	 *
45
	 * @param int $order_id
46
	 */
47
	public function trigger( $order_id ) {
48
49
		if ( $order_id ) {
50
			$this->object       = wc_get_order( $order_id );
51
			$this->recipient    = $this->object->billing_email;
52
53
			$this->find['order-date']      = '{order_date}';
54
			$this->find['order-number']    = '{order_number}';
55
56
			$this->replace['order-date']   = date_i18n( wc_date_format(), strtotime( $this->object->order_date ) );
57
			$this->replace['order-number'] = $this->object->get_order_number();
58
		}
59
60
		if ( ! $this->is_enabled() || ! $this->get_recipient() ) {
61
			return;
62
		}
63
64
		$this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
65
	}
66
67
	/**
68
	 * Get content html.
69
	 *
70
	 * @access public
71
	 * @return string
72
	 */
73
	public function get_content_html() {
74
		return wc_get_template_html( $this->template_html, array(
75
			'order'         => $this->object,
76
			'email_heading' => $this->get_heading(),
77
			'sent_to_admin' => false,
78
			'plain_text'    => false,
79
			'email'			=> $this
80
		) );
81
	}
82
83
	/**
84
	 * Get content plain.
85
	 *
86
	 * @access public
87
	 * @return string
88
	 */
89
	public function get_content_plain() {
90
		return wc_get_template_html( $this->template_plain, array(
91
			'order'         => $this->object,
92
			'email_heading' => $this->get_heading(),
93
			'sent_to_admin' => false,
94
			'plain_text'    => true,
95
			'email'			=> $this
96
		) );
97
	}
98
}
99
100
endif;
101
102
return new WC_Email_Customer_Processing_Order();
103