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 / CustomerFailedOrder.php

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

75 lines 2.8 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 * CustomerFailedOrder Class
11 *
12 * @method static CustomerFailedOrder get_instance()
13 */
14 class CustomerFailedOrder extends BaseEmail {
15 use SingletonTrait;
16
17 protected function __construct() {
18 $emails = \WC_Emails::instance()->get_emails();
19 $email = $emails['WC_Email_Customer_Failed_Order'] ?? null;
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 = __( 'Sorry, your order was unsuccessful', 'woocommerce' );
35 $email_text_1 = __( 'Hi [yaymail_billing_first_name]', 'woocommerce' );
36 $email_text_2 = __( 'Unfortunately, we couldn\'t complete your order due to an issue with your payment method.', 'woocommerce' );
37 $email_text_3 = __( 'If you\'d like to continue with your purchase, please return to [yaymail_site_name] and try a different method of payment.', 'woocommerce' );
38 $email_text_4 = __( 'Your order details are as follows:', 'woocommerce' );
39
40 $default_elements = ElementsLoader::load_elements(
41 [
42 [
43 'type' => 'Logo',
44 ],
45 [
46 'type' => 'Heading',
47 'attributes' => [
48 'rich_text' => $email_title,
49 ],
50 ],
51 [
52 'type' => 'Text',
53 'attributes' => [
54 'rich_text' => '<p><span>' . $email_text_1 . '</span></p><br/><p><span>' . $email_text_2 . '</span></p><br/><p><span>' . $email_text_3 . '</span></p><br/><p><span>' . $email_text_4 . '</span></p>',
55 ],
56 ],
57 [
58 'type' => 'OrderDetails',
59 ],
60 [
61 'type' => 'BillingShippingAddress',
62 ],
63 [
64 'type' => 'Footer',
65 ],
66 ]
67 );
68 return $default_elements;
69 }
70
71 public function get_template_path() {
72 return yaymail_get_template( 'emails/customer-failed-order.php', '', YAYMAIL_PLUGIN_PATH . 'templates/' );
73 }
74 }
75