PluginProbe
YayMail – WooCommerce Email Customizer / 4.4.2
YayMail – WooCommerce Email Customizer v4.4.2
4.4.4 4.4.3 4.4.2 4.4.1 trunk 1.9.6 2.1.4 2.1.5 3.2.2 3.2.6 3.2.7.1 3.2.8.1 3.2.9 3.3 3.3.1 3.3.4 3.3.5 3.3.6 3.3.7 3.3.8 3.3.9 3.4 3.4.1 3.4.2 3.4.3 All 55 releases
yaymail / src / Emails / CustomerNote.php

CustomerNote.php in YayMail – WooCommerce Email Customizer 4.4.2, at src/Emails/CustomerNote.php

89 lines 3.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace YayMail\Emails;
4
5 use YayMail\Abstracts\BaseEmail;
6 use YayMail\Elements\ElementsLoader;
7 use YayMail\Utils\SingletonTrait;
8
9 /**
10 * CustomerNote Class
11 *
12 * @method static CustomerNote get_instance()
13 */
14 class CustomerNote extends BaseEmail {
15 use SingletonTrait;
16
17 protected function __construct() {
18 $emails = \WC_Emails::instance()->get_emails();
19 $email = $emails['WC_Email_Customer_Note'];
20 if ( ! $email ) {
21 return;
22 }
23 $this->id = $email->id;
24 $this->title = $email->get_title();
25 $this->root_email = $email;
26 $this->recipient = function_exists( 'yaymail_get_email_recipient_zone' ) ? yaymail_get_email_recipient_zone( $email ) : '';
27
28 $this->render_priority = apply_filters( 'yaymail_email_render_priority', $this->render_priority, $this->id );
29 add_filter( 'wc_get_template', [ $this, 'get_template_file' ], $this->render_priority ?? 10, 3 );
30 $this->maybe_disable_block_email_editor();
31 }
32
33 public function get_default_elements() {
34 $email_title = __( 'A note has been added to your order', 'woocommerce' );
35 // translators: customer name.
36 $email_hi = sprintf( esc_html__( 'Hi %s,', 'woocommerce' ), '[yaymail_billing_first_name]' );
37 $email_text = esc_html__( 'The following note has been added to your order:', 'woocommerce' );
38 $email_text_1 = esc_html__( 'As a reminder, here are your order details:', 'woocommerce' );
39 $additional_text = __( 'Thanks for reading.', 'woocommerce' );
40
41 $default_elements = ElementsLoader::load_elements(
42 [
43 [
44 'type' => 'Logo',
45 ],
46 [
47 'type' => 'Heading',
48 'attributes' => [
49 'rich_text' => $email_title,
50 ],
51 ],
52 [
53 'type' => 'Text',
54 'attributes' => [
55 'rich_text' => '<p><span>' . $email_hi . '</span></p><p><span>' . $email_text . '</span></p><p style=\"margin: 0px; padding-left: 40px;\"><span> [yaymail_customer_note]</span></p><p><span>' . $email_text_1 . '</span></p>',
56 ],
57 ],
58 [
59 'type' => 'OrderDetails',
60 ],
61 [
62 'type' => 'BillingShippingAddress',
63 ],
64 [
65 'type' => 'Text',
66 'attributes' => [
67 'rich_text' => '<p><span>' . $additional_text . '</span></p>',
68 'padding' => [
69 'top' => '0',
70 'right' => '50',
71 'bottom' => '38',
72 'left' => '50',
73 ],
74 ],
75 ],
76 [
77 'type' => 'Footer',
78 ],
79 ]
80 );
81
82 return $default_elements;
83 }
84
85 public function get_template_path() {
86 return yaymail_get_template( 'emails/customer-note.php', '', YAYMAIL_PLUGIN_PATH . 'templates/' );
87 }
88 }
89