1 <?php
2
3 if ( ! defined( 'ABSPATH' ) ) exit;
4
5 if ( ! class_exists( 'WC_Email_Customer_Note' ) ) :
6
7 8 9 10 11 12 13 14 15 16 17
18 class WC_Email_Customer_Note extends WC_Email {
19
20 var $customer_note;
21
22 23 24 25 26 27
28 function __construct() {
29
30 $this->id = 'customer_note';
31 $this->title = __( 'Customer note', 'woocommerce' );
32 $this->description = __( 'Customer note emails are sent when you add a note to an order.', 'woocommerce' );
33
34 $this->template_html = 'emails/customer-note.php';
35 $this->template_plain = 'emails/plain/customer-note.php';
36
37 $this->subject = __( 'Note added to your {site_title} order from {order_date}', 'woocommerce');
38 $this->heading = __( 'A note has been added to your order', 'woocommerce');
39
40
41 add_action( 'woocommerce_new_customer_note_notification', array( $this, 'trigger' ) );
42
43
44 parent::__construct();
45 }
46
47 48 49 50 51 52
53 function trigger( $args ) {
54
55 if ( $args ) {
56
57 $defaults = array(
58 'order_id' => '',
59 'customer_note' => ''
60 );
61
62 $args = wp_parse_args( $args, $defaults );
63
64 extract( $args );
65
66 $this->object = new WC_Order( $order_id );
67 $this->recipient = $this->object->billing_email;
68 $this->customer_note = $customer_note;
69
70 $this->find[] = '{order_date}';
71 $this->replace[] = date_i18n( woocommerce_date_format(), strtotime( $this->object->order_date ) );
72
73 $this->find[] = '{order_number}';
74 $this->replace[] = $this->object->get_order_number();
75 }
76
77 if ( ! $this->is_enabled() || ! $this->get_recipient() )
78 return;
79
80 $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
81 }
82
83 84 85 86 87 88
89 function get_content_html() {
90 ob_start();
91 wc_get_template( $this->template_html, array(
92 'order' => $this->object,
93 'email_heading' => $this->get_heading(),
94 'customer_note' => $this->customer_note,
95 'sent_to_admin' => false,
96 'plain_text' => false
97 ) );
98 return ob_get_clean();
99 }
100
101 102 103 104 105 106
107 function get_content_plain() {
108 ob_start();
109 wc_get_template( $this->template_plain, array(
110 'order' => $this->object,
111 'email_heading' => $this->get_heading(),
112 'customer_note' => $this->customer_note,
113 'sent_to_admin' => false,
114 'plain_text' => true
115 ) );
116 return ob_get_clean();
117 }
118 }
119
120 endif;
121
122 return new WC_Email_Customer_Note();