| @@ -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', |
| @@ -179,9 +192,11 @@ | ||
| 179 | 192 | $order_item = $order->get_item( $order_item_id ); |
| 180 | 193 | |
| 181 | 194 | $this->product_name = $order_item->get_name(); |
| 182 | 195 | $this->qty = $order_item->get_quantity(); |
| 183 | - $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 ); | |
| 184 | 199 | } |
| 185 | 200 | |
| 186 | 201 | /** |
| 187 | 202 | * Filter WooCommerce template directory. |