PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.4.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.4.0
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 / SubscriptionStockPaused.php

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

82 lines 2.0 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\Traits\Email;
6 use WC_Email;
7
8 /**
9 * Subscription paused because the product is low on stock (Customer).
10 */
11 class SubscriptionStockPaused extends WC_Email {
12
13 use Email;
14
15 /**
16 * Initialize the class.
17 */
18 public function __construct() {
19 $this->customer_email = true;
20
21 $this->id = 'subscrpt_subscription_stock_paused_email';
22 $this->title = __( 'Subscription paused (low stock)', 'subscription' );
23 $this->description = __( 'This email is sent to the customer when a subscription is paused because its product ran low on stock.', 'subscription' );
24
25 // email template path.
26 $this->set_template( $this->id );
27
28 // Triggers for this email.
29 add_action( 'subscrpt_subscription_stock_paused_email_notification', array( $this, 'trigger' ) );
30
31 // Call parent constructor.
32 parent::__construct();
33 }
34
35 /**
36 * Get default subject.
37 *
38 * @return string
39 */
40 public function get_default_subject(): string {
41 return __( '#{subscription_id} subscription paused', 'subscription' );
42 }
43
44 /**
45 * Get the customer email.
46 *
47 * @return string
48 */
49 public function get_recipient(): string {
50 return get_the_author_meta( 'email', get_post_field( 'post_author', $this->subscription_id ) );
51 }
52
53 /**
54 * Trigger the mail.
55 *
56 * @param int $subscription_id Subscription id.
57 *
58 * @return void
59 */
60 public function trigger( int $subscription_id ) {
61 if ( 'no' === $this->enabled ) {
62 return;
63 }
64 $this->placeholders['{subscription_id}'] = $subscription_id;
65 $this->subscription_id = $subscription_id;
66
67 $this->set_table_data();
68
69 $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() );
70 }
71
72 /**
73 * Initialize form fields for settings.
74 *
75 * @return void
76 */
77 public function init_form_fields() {
78 parent::init_form_fields();
79 unset( $this->form_fields['additional_content'] );
80 }
81 }
82