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

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

91 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 Expired Mail to Customer.
11 */
12 class SubscriptionExpired extends WC_Email {
13
14 use Email;
15
16 /**
17 *
18 * Initialize the class.
19 */
20 public function __construct() {
21 $this->customer_email = true;
22
23 $this->id = 'subscrpt_subscription_expired_email';
24 $this->title = __( 'Subscription expired', 'subscription' );
25 $this->description = __( 'This email is sent to customer when a subscription expired.', 'subscription' );
26
27 // email template path.
28 $this->set_template( $this->id );
29
30 // Triggers for this email.
31 add_action( 'subscrpt_subscription_expired_email_notification', array( $this, 'trigger' ) );
32
33 // Call parent constructor.
34 parent::__construct();
35 }
36
37 /**
38 * Get default subject.
39 *
40 * @return string
41 */
42 public function get_default_subject(): string {
43 return __( '#{subscription_id} subscription expired!', 'subscription' );
44 }
45
46 /**
47 * Get the customer email.
48 *
49 * @return string
50 */
51 public function get_recipient(): string {
52 return get_the_author_meta( 'email', get_post_field( 'post_author', $this->subscription_id ) );
53 }
54
55 /**
56 * Trigger the mail.
57 *
58 * @param int $subscription_id Subscription id.
59 *
60 * @return void
61 */
62 public function trigger( int $subscription_id ) {
63 if ( 'no' === $this->enabled ) {
64 return;
65 }
66 $this->placeholders['{subscription_id}'] = $subscription_id;
67 $this->subscription_id = $subscription_id;
68
69 // In the customer's language, not the site's or whoever triggered it.
70 $switched = Multilingual::switch_email_language( $this, $subscription_id );
71
72 $this->set_table_data();
73
74 $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
75
76 if ( $switched ) {
77 Multilingual::restore_email_language( $this );
78 }
79 }
80
81 /**
82 * Initialize form fields for settings.
83 *
84 * @return void
85 */
86 public function init_form_fields() {
87 parent::init_form_fields();
88 unset( $this->form_fields['additional_content'] );
89 }
90 }
91