| 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 |
* CustomerCancelledOrder Class |
| 11 |
* |
| 12 |
* @method static CustomerCancelledOrder get_instance() |
| 13 |
*/ |
| 14 |
class CustomerCancelledOrder extends BaseEmail { |
| 15 |
use SingletonTrait; |
| 16 |
|
| 17 |
protected function __construct() { |
| 18 |
$emails = \WC_Emails::instance()->get_emails(); |
| 19 |
$email = $emails['WC_Email_Customer_Cancelled_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 = __( 'Order Cancelled: #{order_number}', 'woocommerce' ); |
| 35 |
$email_title = str_replace( '#{order_number}', '', $email_title ); |
| 36 |
// translators: %1$s: order id, %2$s: customer name. |
| 37 |
$email_text = sprintf( esc_html__( 'We’re getting in touch to let you know that your order #%1$s has been cancelled.', 'woocommerce' ), '[yaymail_order_number is_plain="true"]' ); |
| 38 |
$additional_text = __( 'Thanks for reading.', '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 . ' #[yaymail_order_number is_plain="true"]', |
| 49 |
], |
| 50 |
], |
| 51 |
[ |
| 52 |
'type' => 'Text', |
| 53 |
'attributes' => [ |
| 54 |
'rich_text' => '<p><span>' . $email_text . '</span></p>', |
| 55 |
], |
| 56 |
], |
| 57 |
[ |
| 58 |
'type' => 'OrderDetails', |
| 59 |
], |
| 60 |
[ |
| 61 |
'type' => 'BillingShippingAddress', |
| 62 |
], |
| 63 |
[ |
| 64 |
'type' => 'Text', |
| 65 |
'attributes' => [ |
| 66 |
'rich_text' => '<p><span>' . $additional_text . '</span></p>', |
| 67 |
'padding' => [ |
| 68 |
'top' => '0', |
| 69 |
'right' => '50', |
| 70 |
'bottom' => '38', |
| 71 |
'left' => '50', |
| 72 |
], |
| 73 |
], |
| 74 |
], |
| 75 |
[ |
| 76 |
'type' => 'Footer', |
| 77 |
], |
| 78 |
] |
| 79 |
); |
| 80 |
|
| 81 |
return $default_elements; |
| 82 |
} |
| 83 |
|
| 84 |
public function get_template_path() { |
| 85 |
return yaymail_get_template( 'emails/customer-cancelled-order.php', '', YAYMAIL_PLUGIN_PATH . 'templates/' ); |
| 86 |
} |
| 87 |
} |
| 88 |
|