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
← All changes | includes/Traits/Email.php +27 -8 1.9.5 → 2.4.0 View file →
@@ -1,5 +1,10 @@
1 1 <?php
2 +/**
3 + * Shared email behaviour for subscription mails.
4 + *
5 + * @package SpringDevs\Subscription\Traits
6 + */
2 7
3 8 namespace SpringDevs\Subscription\Traits;
4 9
5 10 use Exception;
@@ -24,8 +29,12 @@
24 29 'subscrpt_subscription_cancelled_email' => array(
25 30 'html' => 'emails/subscription-cancelled-html.php',
26 31 'plain' => 'emails/plains/subscription-cancelled-plain.php',
27 32 ),
33 + 'subscrpt_subscription_stock_paused_email' => array(
34 + 'html' => 'emails/subscription-stock-paused-html.php',
35 + 'plain' => 'emails/plains/subscription-stock-paused-plain.php',
36 + ),
28 37 'subscrpt_renew_reminder' => array(
29 38 'html' => 'emails/renew-reminder-html.php',
30 39 'plain' => 'emails/plains/renew-reminder-plain.php',
31 40 ),
@@ -125,18 +134,22 @@
125 134 // Build view subscription url & set it to mail extra data.
126 135 $view_subs_endpoint = Subscription::get_user_endpoint( 'view_subs' );
127 136 $view_subscription_url = wc_get_endpoint_url( $view_subs_endpoint, $this->subscription_id, wc_get_page_permalink( 'myaccount' ) );
128 137
138 + // Admin-facing mails link to the wp-admin details page instead of My Account.
139 + $admin_subscription_url = admin_url( 'admin.php?page=wp-subscription-details&id=' . $this->subscription_id );
140 +
129 141 return wc_get_template_html(
130 142 $path,
131 143 array_merge(
132 144 array(
133 - 'id' => $this->subscription_id,
134 - 'email_heading' => $this->get_heading(),
135 - 'product_name' => $this->product_name,
136 - 'qty' => $this->qty,
137 - 'amount' => $this->amount,
138 - 'view_subscription_url' => $view_subscription_url,
145 + 'id' => $this->subscription_id,
146 + 'email_heading' => $this->get_heading(),
147 + 'product_name' => $this->product_name,
148 + 'qty' => $this->qty,
149 + 'amount' => $this->amount,
150 + 'view_subscription_url' => $view_subscription_url,
151 + 'admin_subscription_url' => $admin_subscription_url,
139 152 ),
140 153 $this->extra
141 154 ),
142 155 'subscription',
@@ -170,14 +183,20 @@
170 183 $order_id = wc_get_order_id_by_order_item_id( $order_item_id );
171 184 } catch ( Exception $e ) {
172 185 return;
173 186 }
174 - $order = wc_get_order( $order_id );
187 + $order = wc_get_order( $order_id );
188 + if ( ! $order ) {
189 + return;
190 + }
191 +
175 192 $order_item = $order->get_item( $order_item_id );
176 193
177 194 $this->product_name = $order_item->get_name();
178 195 $this->qty = $order_item->get_quantity();
179 - $this->amount = Helper::format_price_with_order_item( get_post_meta( $this->subscription_id, '_subscrpt_price', true ), $order_item->get_id() );
196 +
197 + // Text form, not the struck-through markup: every one of these emails renders in plain text too.
198 + $this->amount = Helper::get_subscription_recurring_price_text( $this->subscription_id, $order_item );
180 199 }
181 200
182 201 /**
183 202 * Filter WooCommerce template directory.