view-subscription.php
17.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
<?php
/**
* View Subscription
*
* Shows the details of a particular subscription on the account page
*
* @author Prospress
* @package WooCommerce_Subscription/Templates
* @version 2.0
*/
if (!defined('ABSPATH')) {
exit; // Exit if accessed directly
}
if (empty($subscription)) {
global $wp;
if (!isset($wp->query_vars['view-subscription']) || 'shop_subscription' != get_post_type(absint($wp->query_vars['view-subscription'])) || !current_user_can('view_order', absint($wp->query_vars['view-subscription']))) {
echo '<div class="woocommerce-error">' . esc_html__('Invalid Subscription.', 'woocommerce-subscriptions') . ' <a href="' . esc_url(wc_get_page_permalink('myaccount')) . '" class="wc-forward">' . esc_html__('My Account', 'woocommerce-subscriptions') . '</a>' . '</div>';
return;
}
$subscription = wcs_get_subscription($wp->query_vars['view-subscription']);
}
if ($subscription->post->post_status == 'wc-cancelled') {
?>
<div id="cancelled_account">
<?php
$actions = wcs_get_all_user_actions_for_subscription($subscription, get_current_user_id());
if (!empty($actions)) :
foreach ($actions as $key => $action) :
?>
<a href="<?php echo esc_url($action['url']); ?>" class="button <?php echo sanitize_html_class($key) ?>"><?php echo esc_html($action['name']); ?></a>
<?php
endforeach;
endif;
?>
<div class="thank_message">
Thanks for being a part of our journey, all the best! – Marty & Steve
</div>
<div>
<img src="/wp-content/themes/reize/assets/images/General_9.png" scale="0">
</div>
</div>
<script>
jQuery(document).ready(function ($) {
$('.entry-title').html('Cancelled Account');
// ga('send', 'pageview', '/virtual/account-cancellation/');
});
</script>
<?php
} else {
wc_print_notices();
if (!WC_Subscriptions::is_woocommerce_pre('2.6')) {
wc_get_template('myaccount/navigation.php');
echo '<div class="woocommerce-MyAccount-content">';
}
?>
<table class="shop_table subscription_details">
<tr>
<td><?php esc_html_e('Status', 'woocommerce-subscriptions'); ?></td>
<td><?php echo esc_html(wcs_get_subscription_status_name($subscription->get_status())); ?></td>
</tr>
<tr>
<td><?php echo esc_html_x('Start Date', 'table heading', 'woocommerce-subscriptions'); ?></td>
<td><?php echo esc_html($subscription->get_date_to_display('start')); ?></td>
</tr>
<?php
foreach (array(
'last_payment' => _x('Last Payment Date', 'admin subscription table header', 'woocommerce-subscriptions'),
'next_payment' => _x('Next Payment Date', 'admin subscription table header', 'woocommerce-subscriptions'),
'end' => _x('End Date', 'table heading', 'woocommerce-subscriptions'),
'trial end' => _x('Trial End Date', 'admin subscription table header', 'woocommerce-subscriptions'),
) as $date_type => $date_title) :
?>
<?php $date = $subscription->get_date($date_type); ?>
<?php if (!empty($date)) : ?>
<tr>
<td><?php echo esc_html($date_title); ?></td>
<td><?php echo esc_html($subscription->get_date_to_display($date_type)); ?></td>
</tr>
<?php endif; ?>
<?php endforeach; ?>
<?php $actions = wcs_get_all_user_actions_for_subscription($subscription, get_current_user_id()); ?>
<?php if (!empty($actions)) : ?>
<tr>
<td><?php esc_html_e('Actions', 'woocommerce-subscriptions'); ?></td>
<td>
<?php foreach ($actions as $key => $action) : ?>
<a href="<?php echo esc_url($action['url']); ?>" class="button <?php echo sanitize_html_class($key) ?>"><?php echo esc_html($action['name']); ?></a>
<?php endforeach; ?>
</td>
</tr>
<?php endif; ?>
</table>
<?php if ($notes = $subscription->get_customer_order_notes()) :
?>
<h2><?php esc_html_e('Subscription Updates', 'woocommerce-subscriptions'); ?></h2>
<ol class="commentlist notes">
<?php foreach ($notes as $note) : ?>
<li class="comment note">
<div class="comment_container">
<div class="comment-text">
<p class="meta"><?php echo esc_html(date_i18n(_x('l jS \o\f F Y, h:ia', 'date on subscription updates list. Will be localized', 'woocommerce-subscriptions'), strtotime($note->comment_date))); ?></p>
<div class="description">
<?php echo wp_kses_post(wpautop(wptexturize($note->comment_content))); ?>
</div>
<div class="clear"></div>
</div>
<div class="clear"></div>
</div>
</li>
<?php endforeach; ?>
</ol>
<?php endif; ?>
<?php $allow_remove_item = wcs_can_items_be_removed($subscription); ?>
<h2><?php esc_html_e('Subscription Totals', 'woocommerce-subscriptions'); ?></h2>
<table class="shop_table order_details">
<thead>
<tr>
<?php if ($allow_remove_item) : ?>
<th class="product-remove" style="width: 3em;"> </th>
<?php endif; ?>
<th class="product-name"><?php echo esc_html_x('Product', 'table headings in notification email', 'woocommerce-subscriptions'); ?></th>
<th class="product-total"><?php echo esc_html_x('Total', 'table heading', 'woocommerce-subscriptions'); ?></th>
</tr>
</thead>
<tbody>
<?php
if (sizeof($subscription->get_items()) > 0) {
foreach ($subscription->get_items() as $item_id => $item) {
$_product = apply_filters('woocommerce_subscriptions_order_item_product', $subscription->get_product_from_item($item), $item);
$item_meta = wcs_get_order_item_meta($item, $_product);
if (apply_filters('woocommerce_order_item_visible', true, $item)) {
?>
<tr class="<?php echo esc_attr(apply_filters('woocommerce_order_item_class', 'order_item', $item, $subscription)); ?>">
<?php if ($allow_remove_item) : ?>
<td class="remove_item"><a href="<?php echo esc_url(WCS_Remove_Item::get_remove_url($subscription->id, $item_id)); ?>" class="remove" onclick="return confirm('<?php printf(esc_html__('Are you sure you want remove this item from your subscription?', 'woocommerce-subscriptions')); ?>');">×</a></td>
<?php endif; ?>
<td class="product-name">
<?php
if ($_product && !$_product->is_visible()) {
echo esc_html(apply_filters('woocommerce_order_item_name', $item['name'], $item));
} else {
echo wp_kses_post(apply_filters('woocommerce_order_item_name', sprintf('<a href="%s">%s</a>', get_permalink($item['product_id']), $item['name']), $item));
}
echo wp_kses_post(apply_filters('woocommerce_order_item_quantity_html', ' <strong class="product-quantity">' . sprintf('× %s', $item['qty']) . '</strong>', $item));
// Allow other plugins to add additional product information here
do_action('woocommerce_order_item_meta_start', $item_id, $item, $subscription);
$item_meta->display();
if ($_product && $_product->exists() && $_product->is_downloadable() && $subscription->is_download_permitted()) {
$download_files = $subscription->get_item_downloads($item);
$i = 0;
$links = array();
foreach ($download_files as $download_id => $file) {
$i++;
// translators: %1$s is the number of the file (only in plural!), %2$s: the name of the file
$link_text = sprintf(_nx('Download file: %2$s', 'Download file %1$s: %2$s', count($download_files), 'Used as link text in view-subscription template', 'woocommerce-subscriptions'), $i, $file['name']);
$links[] = '<small><a href="' . esc_url($file['download_url']) . '">' . esc_html($link_text) . '</a></small>';
}
echo '<br/>' . wp_kses_post(implode('<br/>', $links));
}
// Allow other plugins to add additional product information here
do_action('woocommerce_order_item_meta_end', $item_id, $item, $subscription);
?>
</td>
<td class="product-total">
<?php echo wp_kses_post($subscription->get_formatted_line_subtotal($item)); ?>
</td>
</tr>
<?php
}
if ($subscription->has_status(array('completed', 'processing')) && ( $purchase_note = get_post_meta($_product->id, '_purchase_note', true) )) {
?>
<tr class="product-purchase-note">
<td colspan="3"><?php echo wp_kses_post(wpautop(do_shortcode($purchase_note))); ?></td>
</tr>
<?php
}
}
}
?>
</tbody>
<tfoot>
<?php
$has_refund = false;
if ($total_refunded = $subscription->get_total_refunded()) {
$has_refund = true;
}
if ($totals = $subscription->get_order_item_totals()) {
foreach ($totals as $key => $total) {
$value = $total['value'];
// Check for refund
if ($has_refund && 'order_total' === $key) {
$refunded_tax_del = '';
$refunded_tax_ins = '';
// Tax for inclusive prices
if (wc_tax_enabled() && 'incl' == $subscription->tax_display_cart) {
$tax_del_array = array();
$tax_ins_array = array();
if ('itemized' == get_option('woocommerce_tax_total_display')) {
foreach ($subscription->get_tax_totals() as $code => $tax) {
$tax_del_array[] = sprintf('%s %s', $tax->formatted_amount, $tax->label);
$tax_ins_array[] = sprintf('%s %s', wc_price($tax->amount - $subscription->get_total_tax_refunded_by_rate_id($tax->rate_id), array('currency' => $subscription->get_order_currency())), $tax->label);
}
} else {
$tax_del_array[] = sprintf('%s %s', wc_price($subscription->get_total_tax(), array('currency' => $subscription->get_order_currency())), WC()->countries->tax_or_vat());
$tax_ins_array[] = sprintf('%s %s', wc_price($subscription->get_total_tax() - $subscription->get_total_tax_refunded(), array('currency' => $subscription->get_order_currency())), WC()->countries->tax_or_vat());
}
if (!empty($tax_del_array)) {
// translators: placeholder is price string, denotes tax included in cart/order total
$refunded_tax_del .= ' ' . sprintf(_x('(Includes %s)', 'includes tax', 'woocommerce-subscriptions'), implode(', ', $tax_del_array));
}
if (!empty($tax_ins_array)) {
// translators: placeholder is price string, denotes tax included in cart/order total
$refunded_tax_ins .= ' ' . sprintf(_x('(Includes %s)', 'includes tax', 'woocommerce-subscriptions'), implode(', ', $tax_ins_array));
}
}
$value = '<del>' . strip_tags($subscription->get_formatted_order_total()) . $refunded_tax_del . '</del> <ins>' . wc_price($subscription->get_total() - $total_refunded, array('currency' => $subscription->get_order_currency())) . $refunded_tax_ins . '</ins>';
}
?>
<tr>
<th scope="row" <?php echo ( $allow_remove_item ) ? 'colspan="2"' : ''; ?>><?php echo esc_html($total['label']); ?></th>
<td><?php echo wp_kses_post($value); ?></td>
</tr>
<?php
}
}
// Check for refund
if ($has_refund) {
?>
<tr>
<th scope="row"><?php esc_html_e('Refunded:', 'woocommerce-subscriptions'); ?></th>
<td>-<?php echo wp_kses_post(wc_price($total_refunded, array('currency' => $subscription->get_order_currency()))); ?></td>
</tr>
<?php
}
// Check for customer note
if ('' != $subscription->customer_note) {
?>
<tr>
<th scope="row"><?php echo esc_html_x('Note:', 'customer note', 'woocommerce-subscriptions'); ?></th>
<td><?php echo wp_kses_post(wptexturize($subscription->customer_note)); ?></td>
</tr>
<?php } ?>
</tfoot>
</table>
<?php do_action('woocommerce_subscription_details_after_subscription_table', $subscription); ?>
<header>
<h2><?php esc_html_e('Customer details', 'woocommerce-subscriptions'); ?></h2>
</header>
<table class="shop_table shop_table_responsive customer_details">
<?php
if ($subscription->billing_email) {
// translators: there is markup here, hence can't use Email: %s
echo '<tr><th>' . esc_html_x('Email', 'heading in customer details on subscription detail page', 'woocommerce-subscriptions') . '</th><td data-title="' . esc_attr_x('Email', 'Used in data attribute for a td tag, escaped.', 'woocommerce-subscriptions') . '">' . esc_html($subscription->billing_email) . '</td></tr>';
}
if ($subscription->billing_phone) {
// translators: there is markup here, hence can't use Email: %s
echo '<tr><th>' . esc_html_x('Tel', 'heading in customer details on subscription detail page', 'woocommerce-subscriptions') . '</th><td data-title="' . esc_attr_x('Telephone', 'Used in data attribute for a td tag, escaped.', 'woocommerce-subscriptions') . '">' . esc_html($subscription->billing_phone) . '</td></tr>';
}
// Additional customer details hook
do_action('woocommerce_order_details_after_customer_details', $subscription);
?>
</table>
<?php if (!wc_ship_to_billing_address_only() && $subscription->needs_shipping_address() && get_option('woocommerce_calc_shipping') !== 'no') : ?>
<div class="col2-set addresses">
<div class="col-1">
<?php endif; ?>
<header class="title">
<h3><?php esc_html_e('Billing Address', 'woocommerce-subscriptions'); ?></h3>
</header>
<address>
<?php
if (!$subscription->get_formatted_billing_address()) {
echo esc_html_x('N/A', 'no information about something', 'woocommerce-subscriptions');
} else {
echo wp_kses_post($subscription->get_formatted_billing_address());
}
?>
</address>
<?php if (!wc_ship_to_billing_address_only() && $subscription->needs_shipping_address() && get_option('woocommerce_calc_shipping') !== 'no') : ?>
</div><!-- /.col-1 -->
<div class="col-2">
<header class="title">
<h3><?php esc_html_e('Shipping Address', 'woocommerce-subscriptions'); ?></h3>
</header>
<address>
<?php
if (!$subscription->get_formatted_shipping_address()) {
echo esc_html_x('N/A', 'no information about something', 'woocommerce-subscriptions');
} else {
echo wp_kses_post($subscription->get_formatted_shipping_address());
}
?>
</address>
</div><!-- /.col-2 -->
</div><!-- /.col2-set -->
<?php endif; ?>
<?php if (!WC_Subscriptions::is_woocommerce_pre('2.6')) : ?>
</div>
<?php endif; ?>
<div class="clear"></div>
<?php } ?>