PluginProbe
YayMail – WooCommerce Email Customizer / 4.3.4
YayMail – WooCommerce Email Customizer v4.3.4
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 / CustomerInvoice.php

CustomerInvoice.php in YayMail – WooCommerce Email Customizer 4.3.4, at src/Emails/CustomerInvoice.php

92 lines 3.3 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 * CustomerInvoice Class
11 *
12 * @method static CustomerInvoice get_instance()
13 */
14 class CustomerInvoice extends BaseEmail {
15 use SingletonTrait;
16
17 protected function __construct() {
18 $emails = \WC_Emails::instance()->get_emails();
19 $email = $emails['WC_Email_Customer_Invoice'];
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 = __( 'Details for order: #{order_number}', 'woocommerce' );
35 $email_title = str_replace( '#{order_number}', '', $email_title );
36 // translators: customer name.
37 $email_hi = sprintf( esc_html__( 'Hi %s,', 'woocommerce' ), '[yaymail_billing_first_name]' );
38 // translators: order date.
39 $email_text = sprintf( esc_html__( 'Here are the details of your order placed on %s,', 'woocommerce' ), '[yaymail_order_date]' );
40 $additional_text = __( 'Thanks for using {site_url}!', 'woocommerce' );
41 $additional_text = str_replace( '{site_url}!', '', $additional_text );
42
43 $default_elements = ElementsLoader::load_elements(
44 [
45 [
46 'type' => 'Logo',
47 ],
48 [
49 'type' => 'Heading',
50 'attributes' => [
51 'rich_text' => $email_title . '#[yaymail_order_number]',
52 ],
53 ],
54 [
55 'type' => 'Text',
56 'attributes' => [
57 'rich_text' => '<p><span>' . $email_hi . '<br /><br /></span></p><p><span>' . $email_text . '</span></p>',
58 ],
59 ],
60 [
61 'type' => 'OrderDetails',
62 ],
63 [
64 'type' => 'BillingShippingAddress',
65 ],
66 [
67 'type' => 'Text',
68 'attributes' => [
69 'rich_text' => '<p><span>' . $additional_text . '[yaymail_domain]!</span></p>',
70 'padding' => [
71 'top' => '0',
72 'right' => '50',
73 'bottom' => '38',
74 'left' => '50',
75 ],
76 ],
77 ],
78 [
79 'type' => 'Footer',
80 ],
81 ]
82 );
83
84 return $default_elements;
85 }
86
87
88 public function get_template_path() {
89 return yaymail_get_template( 'emails/customer-invoice.php', '', YAYMAIL_PLUGIN_PATH . 'templates/' );
90 }
91 }
92