class-wc-email-cancelled-order.php
6 years ago
class-wc-email-customer-completed-order.php
6 years ago
class-wc-email-customer-invoice.php
6 years ago
class-wc-email-customer-new-account.php
6 years ago
class-wc-email-customer-note.php
6 years ago
class-wc-email-customer-on-hold-order.php
6 years ago
class-wc-email-customer-processing-order.php
6 years ago
class-wc-email-customer-refunded-order.php
6 years ago
class-wc-email-customer-reset-password.php
6 years ago
class-wc-email-failed-order.php
6 years ago
class-wc-email-new-order.php
6 years ago
class-wc-email.php
6 years ago
class-wc-email-customer-note.php
167 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Class WC_Email_Customer_Note file. |
| 4 | * |
| 5 | * @package WooCommerce\Emails |
| 6 | */ |
| 7 | |
| 8 | if ( ! defined( 'ABSPATH' ) ) { |
| 9 | exit; // Exit if accessed directly. |
| 10 | } |
| 11 | |
| 12 | if ( ! class_exists( 'WC_Email_Customer_Note', false ) ) : |
| 13 | |
| 14 | /** |
| 15 | * Customer Note Order Email. |
| 16 | * |
| 17 | * Customer note emails are sent when you add a note to an order. |
| 18 | * |
| 19 | * @class WC_Email_Customer_Note |
| 20 | * @version 3.5.0 |
| 21 | * @package WooCommerce/Classes/Emails |
| 22 | * @extends WC_Email |
| 23 | */ |
| 24 | class WC_Email_Customer_Note extends WC_Email { |
| 25 | |
| 26 | /** |
| 27 | * Customer note. |
| 28 | * |
| 29 | * @var string |
| 30 | */ |
| 31 | public $customer_note; |
| 32 | |
| 33 | /** |
| 34 | * Constructor. |
| 35 | */ |
| 36 | public function __construct() { |
| 37 | $this->id = 'customer_note'; |
| 38 | $this->customer_email = true; |
| 39 | $this->title = __( 'Customer note', 'woocommerce' ); |
| 40 | $this->description = __( 'Customer note emails are sent when you add a note to an order.', 'woocommerce' ); |
| 41 | $this->template_html = 'emails/customer-note.php'; |
| 42 | $this->template_plain = 'emails/plain/customer-note.php'; |
| 43 | $this->placeholders = array( |
| 44 | '{order_date}' => '', |
| 45 | '{order_number}' => '', |
| 46 | ); |
| 47 | |
| 48 | // Triggers. |
| 49 | add_action( 'woocommerce_new_customer_note_notification', array( $this, 'trigger' ) ); |
| 50 | |
| 51 | // Call parent constructor. |
| 52 | parent::__construct(); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Get email subject. |
| 57 | * |
| 58 | * @since 3.1.0 |
| 59 | * @return string |
| 60 | */ |
| 61 | public function get_default_subject() { |
| 62 | return __( 'Note added to your {site_title} order from {order_date}', 'woocommerce' ); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Get email heading. |
| 67 | * |
| 68 | * @since 3.1.0 |
| 69 | * @return string |
| 70 | */ |
| 71 | public function get_default_heading() { |
| 72 | return __( 'A note has been added to your order', 'woocommerce' ); |
| 73 | } |
| 74 | |
| 75 | /** |
| 76 | * Trigger. |
| 77 | * |
| 78 | * @param array $args Email arguments. |
| 79 | */ |
| 80 | public function trigger( $args ) { |
| 81 | $this->setup_locale(); |
| 82 | |
| 83 | if ( ! empty( $args ) ) { |
| 84 | $defaults = array( |
| 85 | 'order_id' => '', |
| 86 | 'customer_note' => '', |
| 87 | ); |
| 88 | |
| 89 | $args = wp_parse_args( $args, $defaults ); |
| 90 | |
| 91 | $order_id = $args['order_id']; |
| 92 | $customer_note = $args['customer_note']; |
| 93 | |
| 94 | if ( $order_id ) { |
| 95 | $this->object = wc_get_order( $order_id ); |
| 96 | |
| 97 | if ( $this->object ) { |
| 98 | $this->recipient = $this->object->get_billing_email(); |
| 99 | $this->customer_note = $customer_note; |
| 100 | $this->placeholders['{order_date}'] = wc_format_datetime( $this->object->get_date_created() ); |
| 101 | $this->placeholders['{order_number}'] = $this->object->get_order_number(); |
| 102 | } |
| 103 | } |
| 104 | } |
| 105 | |
| 106 | if ( $this->is_enabled() && $this->get_recipient() ) { |
| 107 | $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); |
| 108 | } |
| 109 | |
| 110 | $this->restore_locale(); |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Get content html. |
| 115 | * |
| 116 | * @return string |
| 117 | */ |
| 118 | public function get_content_html() { |
| 119 | return wc_get_template_html( |
| 120 | $this->template_html, |
| 121 | array( |
| 122 | 'order' => $this->object, |
| 123 | 'email_heading' => $this->get_heading(), |
| 124 | 'additional_content' => $this->get_additional_content(), |
| 125 | 'customer_note' => $this->customer_note, |
| 126 | 'sent_to_admin' => false, |
| 127 | 'plain_text' => false, |
| 128 | 'email' => $this, |
| 129 | ) |
| 130 | ); |
| 131 | } |
| 132 | |
| 133 | /** |
| 134 | * Get content plain. |
| 135 | * |
| 136 | * @return string |
| 137 | */ |
| 138 | public function get_content_plain() { |
| 139 | return wc_get_template_html( |
| 140 | $this->template_plain, |
| 141 | array( |
| 142 | 'order' => $this->object, |
| 143 | 'email_heading' => $this->get_heading(), |
| 144 | 'additional_content' => $this->get_additional_content(), |
| 145 | 'customer_note' => $this->customer_note, |
| 146 | 'sent_to_admin' => false, |
| 147 | 'plain_text' => true, |
| 148 | 'email' => $this, |
| 149 | ) |
| 150 | ); |
| 151 | } |
| 152 | |
| 153 | /** |
| 154 | * Default content to show below main email content. |
| 155 | * |
| 156 | * @since 3.7.0 |
| 157 | * @return string |
| 158 | */ |
| 159 | public function get_default_additional_content() { |
| 160 | return __( 'Thanks for reading.', 'woocommerce' ); |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | endif; |
| 165 | |
| 166 | return new WC_Email_Customer_Note(); |
| 167 |