PluginProbe
YayMail – WooCommerce Email Customizer / trunk
YayMail – WooCommerce Email Customizer vtrunk
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 / CustomerPOSRefundedOrder.php

CustomerPOSRefundedOrder.php in YayMail – WooCommerce Email Customizer trunk, at src/Emails/CustomerPOSRefundedOrder.php

118 lines 4.0 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 use YayMail\YayMailTemplate;
9
10 /**
11 * CustomerPOSRefundedOrder Class
12 * From WC 9.9.3
13 *
14 * @since 4.0.6
15 * @method static CustomerPOSRefundedOrder get_instance()
16 */
17 class CustomerPOSRefundedOrder extends BaseEmail {
18 use SingletonTrait;
19
20 protected function __construct() {
21 $emails = \WC_Emails::instance()->get_emails();
22 $email = $emails['WC_Email_Customer_POS_Refunded_Order'] ?? null;
23 if ( ! $email ) {
24 return;
25 }
26
27 $this->id = $email->id;
28 $this->title = $email->get_title();
29 $this->root_email = $email;
30 $this->recipient = function_exists( 'yaymail_get_email_recipient_zone' ) ? yaymail_get_email_recipient_zone( $email ) : '';
31
32 $this->render_priority = apply_filters( 'yaymail_email_render_priority', $this->render_priority, $this->id );
33 add_filter( 'wc_get_template', [ $this, 'get_template_file' ], $this->render_priority ?? 10, 3 );
34 $this->maybe_disable_block_email_editor();
35 }
36
37 public function get_default_elements() {
38 $email_title = '[yaymail_get_heading]';
39 // translators: customer name.
40 $email_hi = sprintf( esc_html__( 'Hi %s,', 'woocommerce' ), '[yaymail_billing_first_name]' );
41 // translators: site name.
42 $email_text = sprintf( esc_html__( 'Your order on %s has been %s. There are more details below for your reference:', 'woocommerce' ), '[yaymail_site_name]', '[yaymail_refund_type]' );
43 $additional_text = __( 'We hope to see you again soon.', 'woocommerce' );
44
45 $default_elements = ElementsLoader::load_elements(
46 [
47 [
48 'type' => 'Logo',
49 ],
50 [
51 'type' => 'Heading',
52 'attributes' => [
53 'rich_text' => $email_title,
54 ],
55 ],
56 [
57 'type' => 'Text',
58 'attributes' => [
59 'rich_text' => '<p><span>' . $email_hi . '<br /></span></p><p><span>' . $email_text . '</span></p>',
60 ],
61 ],
62 [
63 'type' => 'OrderDetails',
64 ],
65 [
66 'type' => 'BillingShippingAddress',
67 ],
68 [
69 'type' => 'Text',
70 'attributes' => [
71 'rich_text' => '<p><span>' . $additional_text . '</span></p>',
72 'padding' => [
73 'top' => '0',
74 'right' => '50',
75 'bottom' => '38',
76 'left' => '50',
77 ],
78 ],
79 ],
80 [
81 'type' => 'Footer',
82 ],
83 ]
84 );
85
86 return $default_elements;
87 }
88
89 public function get_template_file( $located, $template_name, $args ) {
90 if ( ! isset( $args['email'] ) ) {
91 return $located;
92 }
93 if ( ! $args['email'] instanceof \WC_Email || ! $args['email'] instanceof \WC_Email_Customer_POS_Refunded_Order ) {
94 return $located;
95 }
96 $template_path = $this->get_template_path();
97 if ( ! file_exists( $template_path ) ) {
98 return $located;
99 }
100
101 $order = apply_filters( 'yaymail_order_for_language', isset( $args['order'] ) ? $args['order'] : null, $args );
102
103 $language = $this->get_language( $order );
104
105 $this->template = new YayMailTemplate( $this->id, $language );
106
107 if ( ! $this->template->is_enabled() ) {
108 return $located;
109 }
110
111 return $template_path;
112 }
113
114 public function get_template_path() {
115 return yaymail_get_template( 'emails/customer-pos-refunded-order.php', '', YAYMAIL_PLUGIN_PATH . 'templates/' );
116 }
117 }
118