PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / trunk
Subscriptions for WooCommerce with Stripe Recurring Payments vtrunk
2.4.0 2.3.0 2.2.0 2.1.0 2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 All 65 releases
subscription / includes / Illuminate / Emails / SubscriptionCancelled.php

SubscriptionCancelled.php in Subscriptions for WooCommerce with Stripe Recurring Payments trunk, at includes/Illuminate/Emails/SubscriptionCancelled.php

90 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace SpringDevs\Subscription\Illuminate\Emails;
4
5 use SpringDevs\Subscription\Illuminate\Multilingual;
6 use SpringDevs\Subscription\Traits\Email;
7 use WC_Email;
8
9 /**
10 * Subscription canceled mail class.
11 */
12 class SubscriptionCancelled extends WC_Email {
13
14 use Email;
15
16 /**
17 * Initialize the class.
18 */
19 public function __construct() {
20 $this->customer_email = true;
21
22 $this->id = 'subscrpt_subscription_cancelled_email';
23 $this->title = __( 'Subscription cancelled', 'subscription' );
24 $this->description = __( 'This email is sent to customer when a subscription canceled.', 'subscription' );
25
26 // email template path.
27 $this->set_template( $this->id );
28
29 // Triggers for this email.
30 add_action( 'subscrpt_subscription_cancelled_email_notification', array( $this, 'trigger' ) );
31
32 // call the parent constructor.
33 parent::__construct();
34 }
35
36 /**
37 * Get default subject.
38 *
39 * @return string
40 */
41 public function get_default_subject(): string {
42 return __( '#{subscription_id} subscription cancelled!', 'subscription' );
43 }
44
45 /**
46 * Get the customer email.
47 *
48 * @return string
49 */
50 public function get_recipient(): string {
51 return get_the_author_meta( 'email', get_post_field( 'post_author', $this->subscription_id ) );
52 }
53
54 /**
55 * Trigger the mail.
56 *
57 * @param int $subscription_id Subscription id.
58 *
59 * @return void
60 */
61 public function trigger( int $subscription_id ) {
62 if ( 'no' === $this->enabled ) {
63 return;
64 }
65 $this->placeholders['{subscription_id}'] = $subscription_id;
66 $this->subscription_id = $subscription_id;
67
68 // In the customer's language, not the site's or whoever triggered it.
69 $switched = Multilingual::switch_email_language( $this, $subscription_id );
70
71 $this->set_table_data();
72
73 $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
74
75 if ( $switched ) {
76 Multilingual::restore_email_language( $this );
77 }
78 }
79
80 /**
81 * Initialize form fields for settings.
82 *
83 * @return void
84 */
85 public function init_form_fields() {
86 parent::init_form_fields();
87 unset( $this->form_fields['additional_content'] );
88 }
89 }
90