| @@ -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; |
| @@ -125,18 +130,22 @@ | ||
| 125 | 130 | // Build view subscription url & set it to mail extra data. |
| 126 | 131 | $view_subs_endpoint = Subscription::get_user_endpoint( 'view_subs' ); |
| 127 | 132 | $view_subscription_url = wc_get_endpoint_url( $view_subs_endpoint, $this->subscription_id, wc_get_page_permalink( 'myaccount' ) ); |
| 128 | 133 | |
| 134 | + // Admin-facing mails link to the wp-admin details page instead of My Account. | |
| 135 | + $admin_subscription_url = admin_url( 'admin.php?page=wp-subscription-details&id=' . $this->subscription_id ); | |
| 136 | + | |
| 129 | 137 | return wc_get_template_html( |
| 130 | 138 | $path, |
| 131 | 139 | array_merge( |
| 132 | 140 | 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, | |
| 141 | + 'id' => $this->subscription_id, | |
| 142 | + 'email_heading' => $this->get_heading(), | |
| 143 | + 'product_name' => $this->product_name, | |
| 144 | + 'qty' => $this->qty, | |
| 145 | + 'amount' => $this->amount, | |
| 146 | + 'view_subscription_url' => $view_subscription_url, | |
| 147 | + 'admin_subscription_url' => $admin_subscription_url, | |
| 139 | 148 | ), |
| 140 | 149 | $this->extra |
| 141 | 150 | ), |
| 142 | 151 | 'subscription', |
| @@ -179,9 +188,11 @@ | ||
| 179 | 188 | $order_item = $order->get_item( $order_item_id ); |
| 180 | 189 | |
| 181 | 190 | $this->product_name = $order_item->get_name(); |
| 182 | 191 | $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() ); | |
| 192 | + | |
| 193 | + // Text form, not the struck-through markup: every one of these emails renders in plain text too. | |
| 194 | + $this->amount = Helper::get_subscription_recurring_price_text( $this->subscription_id, $order_item ); | |
| 184 | 195 | } |
| 185 | 196 | |
| 186 | 197 | /** |
| 187 | 198 | * Filter WooCommerce template directory. |