MyAccountTag.php
1 month ago
account-settings.tmpl.php
3 years ago
billing-details.tmpl.php
1 year ago
change-password.tmpl.php
1 year ago
dashboard.tmpl.php
3 years ago
delete-account.tmpl.php
1 year ago
downloads.tmpl.php
1 year ago
edit-profile.tmpl.php
1 year ago
email-notifications.tmpl.php
3 years ago
index.php
5 years ago
orders.tmpl.php
3 years ago
subscriptions.tmpl.php
1 year ago
view-order.tmpl.php
1 year ago
view-subscription.tmpl.php
1 year ago
downloads.tmpl.php
74 lines
| 1 | <?php |
| 2 | |
| 3 | use ProfilePress\Core\Membership\DigitalProducts\DownloadService; |
| 4 | use ProfilePress\Core\Membership\Models\Customer\CustomerFactory; |
| 5 | use ProfilePress\Core\Membership\Models\Order\OrderFactory; |
| 6 | |
| 7 | if ( ! defined('ABSPATH')) { |
| 8 | exit; |
| 9 | } |
| 10 | |
| 11 | if ( ! is_user_logged_in()) return; |
| 12 | |
| 13 | $current_user_id = get_current_user_id(); |
| 14 | |
| 15 | $customer = CustomerFactory::fromUserId($current_user_id); |
| 16 | |
| 17 | if ( ! $customer->exists()) return; |
| 18 | |
| 19 | $subs = $customer->get_active_subscriptions(); |
| 20 | |
| 21 | $found = []; |
| 22 | |
| 23 | foreach ($subs as $sub) { |
| 24 | |
| 25 | if ($sub->get_plan()->has_downloads()) { |
| 26 | $found[] = $sub; |
| 27 | } |
| 28 | } |
| 29 | |
| 30 | echo '<div class="profilepress-myaccount-orders-subs">'; |
| 31 | printf('<h2>%s</h2>', esc_html__('Downloads', 'wp-user-avatar')); |
| 32 | if (empty($found)) { |
| 33 | printf('<p class="profilepress-myaccount-alert pp-alert-danger">%s</p>', __('You have no downloads.', 'wp-user-avatar')); |
| 34 | } else { ?> |
| 35 | |
| 36 | <div class="profilepress-myaccount-sub-order-details-table-wrap"> |
| 37 | <table class="ppress-details-table"> |
| 38 | <thead> |
| 39 | <tr> |
| 40 | <th><?php esc_html_e('Plan', 'wp-user-avatar') ?></th> |
| 41 | <th><?php esc_html_e('Product', 'wp-user-avatar') ?></th> |
| 42 | <th><?php esc_html_e('Downloads Remaining', 'wp-user-avatar') ?></th> |
| 43 | <th><?php esc_html_e('Action', 'wp-user-avatar') ?></th> |
| 44 | </tr> |
| 45 | </thead> |
| 46 | <tbody> |
| 47 | <?php foreach ($found as $sub) : ?> |
| 48 | <?php $downloads = $sub->get_plan()->get_downloads(); ?> |
| 49 | <?php $plan = $sub->get_plan(); ?> |
| 50 | <?php $order = OrderFactory::fromId($sub->parent_order_id); ?> |
| 51 | <?php if (is_array($downloads['files']) && ! empty($downloads['files'])) : ?> |
| 52 | <?php $index = 0; ?> |
| 53 | <?php foreach ($downloads['files'] as $file_url => $file_name) : ?> |
| 54 | <?php $download_url = DownloadService::init()->get_download_file_url( |
| 55 | $order->get_order_key(), $index, $downloads['download_expiry'] |
| 56 | ); ?> |
| 57 | <tr> |
| 58 | <td><?php echo esc_html($plan->get_name()) ?></td> |
| 59 | <td><?php echo esc_html($file_name) ?></td> |
| 60 | <td><?php echo DownloadService::init()->get_downloads_remaining($order->get_id(), $plan->get_id(), $file_url) ?></td> |
| 61 | <td> |
| 62 | <a class="ppress-myac-action" href="<?php echo esc_url($download_url) ?>"><?php esc_html_e('Download', 'wp-user-avatar'); ?></a> |
| 63 | </td> |
| 64 | </tr> |
| 65 | <?php $index++; ?> |
| 66 | <?php endforeach; ?> |
| 67 | <?php endif; ?> |
| 68 | <?php endforeach; ?> |
| 69 | </tbody> |
| 70 | </table> |
| 71 | </div> |
| 72 | <?php |
| 73 | } |
| 74 | echo '</div>'; |