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
view-order.tmpl.php
237 lines
| 1 | <?php |
| 2 | |
| 3 | use ProfilePress\Core\Membership\CheckoutFields; |
| 4 | use ProfilePress\Core\Membership\CheckoutFields as CF; |
| 5 | use ProfilePress\Core\Membership\DigitalProducts\DownloadService; |
| 6 | use ProfilePress\Core\Membership\Models\Customer\CustomerFactory; |
| 7 | use ProfilePress\Core\Membership\Models\Order\OrderFactory; |
| 8 | use ProfilePress\Core\Membership\Models\Order\OrderStatus; |
| 9 | use ProfilePress\Core\Membership\Models\Order\OrderType; |
| 10 | use ProfilePress\Core\Membership\Models\Subscription\SubscriptionFactory; |
| 11 | use ProfilePress\Core\Membership\PaymentMethods\PaymentMethods; |
| 12 | use ProfilePress\Core\Membership\Services\Calculator; |
| 13 | use ProfilePress\Core\Membership\Services\TaxService; |
| 14 | use ProfilePress\Core\ShortcodeParser\MyAccount\MyAccountTag; |
| 15 | |
| 16 | if ( ! defined('ABSPATH')) { |
| 17 | exit; |
| 18 | } |
| 19 | |
| 20 | $order = OrderFactory::fromOrderKey(ppressGET_var('order_key')); |
| 21 | |
| 22 | $customer_id = CustomerFactory::fromUserId(get_current_user_id())->id; |
| 23 | |
| 24 | ?> |
| 25 | <div class="profilepress-myaccount-orders-subs"> |
| 26 | |
| 27 | <?php if ( ! $order->exists() || (is_user_logged_in() && $order->customer_id !== $customer_id)) : |
| 28 | |
| 29 | printf('<p class="profilepress-myaccount-alert pp-alert-danger">%s</p>', esc_html__('Invalid order', 'wp-user-avatar')); |
| 30 | |
| 31 | else : $plan = ppress_get_plan($order->plan_id); |
| 32 | $vat_number = $order->get_customer_tax_id(); |
| 33 | $plan_purchase_note = $order->get_plan_purchase_note(); |
| 34 | |
| 35 | do_action('ppress_myaccount_view_order_before_order_details_table', $order, $customer_id); |
| 36 | ?> |
| 37 | |
| 38 | <div class="profilepress-myaccount-order-details-wrap"> |
| 39 | <div class="ppress-details-table-wrap"> |
| 40 | <table class="ppress-details-table"> |
| 41 | <tbody> |
| 42 | <tr> |
| 43 | <td><?php esc_html_e('Order', 'wp-user-avatar'); ?></td> |
| 44 | <td><?= $order->get_reduced_order_key() ?> <?php do_action('ppress_myaccount_view_order_details_order_row', $order); ?></td> |
| 45 | </tr> |
| 46 | <tr> |
| 47 | <td><?php esc_html_e('Date Placed', 'wp-user-avatar'); ?></td> |
| 48 | <td><?= ppress_format_date($order->date_created) ?></td> |
| 49 | </tr> |
| 50 | <tr> |
| 51 | <td><?php esc_html_e('Order Item', 'wp-user-avatar'); ?></td> |
| 52 | <td><?= $plan->name ?> |
| 53 | <span class="ppress-sub-info"><?= ppress_display_amount($plan->price) ?></span></td> |
| 54 | </tr> |
| 55 | <?php if ( ! empty($plan->description)) : ?> |
| 56 | <tr> |
| 57 | <td><?php esc_html_e('Item Description', 'wp-user-avatar'); ?></td> |
| 58 | <td><?= wpautop($plan->description) ?></td> |
| 59 | </tr> |
| 60 | <?php endif; ?> |
| 61 | <?php if ($order->is_completed() && ! empty($plan_purchase_note)): ?> |
| 62 | <tr> |
| 63 | <td><?php esc_html_e('Purchase Note', 'wp-user-avatar'); ?></td> |
| 64 | <td><?= $plan_purchase_note ?></td> |
| 65 | </tr> |
| 66 | <?php endif; ?> |
| 67 | <tr> |
| 68 | <td><?php esc_html_e('Order Status', 'wp-user-avatar'); ?></td> |
| 69 | <td> |
| 70 | <span class="order-status <?= $order->status ?>"><?= OrderStatus::get_label($order->status) ?></span> |
| 71 | </td> |
| 72 | </tr> |
| 73 | <tr> |
| 74 | <td><?php esc_html_e('Order Type', 'wp-user-avatar'); ?></td> |
| 75 | <td> |
| 76 | <span class="order-type <?= $order->order_type ?>"><?= OrderType::get_label($order->order_type) ?></span> |
| 77 | </td> |
| 78 | </tr> |
| 79 | <tr> |
| 80 | <td><?php esc_html_e('Payment Method', 'wp-user-avatar'); ?></td> |
| 81 | <td><?= PaymentMethods::get_instance()->get_by_id($order->payment_method)->title ?></td> |
| 82 | </tr> |
| 83 | <tr> |
| 84 | <td><?php esc_html_e('Billing Address', 'wp-user-avatar'); ?></td> |
| 85 | <td> |
| 86 | <?php |
| 87 | |
| 88 | foreach (CheckoutFields::standard_billing_fields() as $field_id => $field) { |
| 89 | |
| 90 | $method_name = str_replace('ppress_', '', $field_id); |
| 91 | |
| 92 | $detail = $order->$method_name; |
| 93 | |
| 94 | if ( ! empty($detail)) { |
| 95 | |
| 96 | if ($field_id == CF::BILLING_COUNTRY) { |
| 97 | $detail = ppress_array_of_world_countries($detail); |
| 98 | } |
| 99 | |
| 100 | if ($field_id == CF::BILLING_STATE) { |
| 101 | $state = ! empty($order->billing_country) ? ppress_array_of_world_states($order->billing_country) : []; |
| 102 | $detail = ppress_var($state, $detail, $detail, true); |
| 103 | } |
| 104 | |
| 105 | } |
| 106 | |
| 107 | if (empty($detail)) continue; |
| 108 | |
| 109 | echo '<p>'; |
| 110 | printf('<span class="ppress-billing-title">%s:</span> %s', esc_html($field['label']), $detail); |
| 111 | echo '</p>'; |
| 112 | } ?> |
| 113 | </td> |
| 114 | </tr> |
| 115 | <tr> |
| 116 | <td><?php esc_html_e('Subtotal', 'wp-user-avatar'); ?></td> |
| 117 | <td><?= ppress_display_amount($order->subtotal, $order->currency) ?></td> |
| 118 | </tr> |
| 119 | <?php if ( ! Calculator::init($order->discount)->isNegativeOrZero()) : ?> |
| 120 | <tr> |
| 121 | <td><?php esc_html_e('Discount', 'wp-user-avatar'); ?></td> |
| 122 | <td> |
| 123 | <?= ppress_display_amount($order->discount, $order->currency) ?> |
| 124 | <span class="ppress-sub-info"><?= $order->coupon_code ?></span> |
| 125 | </td> |
| 126 | </tr> |
| 127 | <?php endif; ?> |
| 128 | <?php if (TaxService::init()->is_tax_enabled() || Calculator::init($order->tax)->isGreaterThanZero()) : ?> |
| 129 | <tr> |
| 130 | <td><?= TaxService::init()->get_tax_label($order->billing_country) ?></td> |
| 131 | <td><?= ppress_display_amount($order->tax, $order->currency) ?> |
| 132 | <?php if (Calculator::init($order->tax_rate)->isGreaterThanZero()) : ?> |
| 133 | <span class="ppress-sub-info"><?= $order->tax_rate ?>%</span> |
| 134 | <?php elseif (TaxService::init()->is_reverse_charged($order->id)) : ?> |
| 135 | <span class="ppress-sub-info"><?php esc_html_e('Reverse Charged', 'wp-user-avatar') ?></span> |
| 136 | <?php endif; ?> |
| 137 | </td> |
| 138 | </tr> |
| 139 | <?php endif; ?> |
| 140 | <tr> |
| 141 | <td><?php esc_html_e('Total', 'wp-user-avatar'); ?></td> |
| 142 | <td><?= ppress_display_amount($order->total, $order->currency) ?></td> |
| 143 | </tr> |
| 144 | <?php if ( ! empty($vat_number)): ?> |
| 145 | <tr> |
| 146 | <td><?php esc_html_e('VAT Number', 'wp-user-avatar'); ?></td> |
| 147 | <td><?= $vat_number ?></td> |
| 148 | </tr> |
| 149 | <?php endif; ?> |
| 150 | </tbody> |
| 151 | </table> |
| 152 | </div> |
| 153 | </div> |
| 154 | |
| 155 | <?php $subscription = SubscriptionFactory::fromId($order->subscription_id); ?> |
| 156 | |
| 157 | <?php if ($subscription->exists()): $view_sub_url = add_query_arg(['sub_id' => $subscription->id], MyAccountTag::get_endpoint_url('list-subscriptions')) ?> |
| 158 | |
| 159 | <h2><?= esc_html__('Subscription', 'wp-user-avatar') ?></h2> |
| 160 | |
| 161 | <div class="profilepress-myaccount-sub-order-details-wrap"> |
| 162 | <div class="profilepress-myaccount-sub-order-details-table-wrap"> |
| 163 | <table class="ppress-details-table"> |
| 164 | <thead> |
| 165 | <tr> |
| 166 | <th><?php esc_html_e('Subscription', 'wp-user-avatar') ?></th> |
| 167 | <th><?php esc_html_e('Terms', 'wp-user-avatar') ?></th> |
| 168 | <th><?php esc_html_e('Status', 'wp-user-avatar') ?></th> |
| 169 | <th><?php echo $subscription->get_renewal_expiration_date_label() ?></th> |
| 170 | </tr> |
| 171 | </thead> |
| 172 | <tbody> |
| 173 | <tr> |
| 174 | <td> |
| 175 | <a href="<?php echo esc_url($view_sub_url) ?>"><?= $subscription->get_plan()->get_name() ?></a> |
| 176 | </td> |
| 177 | <td><?= $subscription->get_subscription_terms() ?></td> |
| 178 | <td><?= $subscription->get_status_label() ?></td> |
| 179 | <td><?= $subscription->get_formatted_expiration_date() ?></td> |
| 180 | </tr> |
| 181 | </tbody> |
| 182 | </table> |
| 183 | </div> |
| 184 | </div> |
| 185 | |
| 186 | |
| 187 | <?php endif; ?> |
| 188 | |
| 189 | <?php if ($order->is_completed() && SubscriptionFactory::fromId($order->subscription_id)->is_active()) : $downloads = $plan->get_downloads(); ?> |
| 190 | |
| 191 | <?php if (isset($downloads['files']) && is_array($downloads['files']) && ! empty($downloads['files'])) : ?> |
| 192 | |
| 193 | <h2><?= esc_html__('Downloads', 'wp-user-avatar') ?></h2> |
| 194 | |
| 195 | <div class="profilepress-myaccount-sub-order-details-wrap"> |
| 196 | <div class="profilepress-myaccount-sub-order-details-table-wrap"> |
| 197 | <table class="ppress-details-table"> |
| 198 | <thead> |
| 199 | <tr> |
| 200 | <th><?php esc_html_e('Product', 'wp-user-avatar') ?></th> |
| 201 | <th><?php esc_html_e('Downloads Remaining', 'wp-user-avatar') ?></th> |
| 202 | <th><?php esc_html_e('Action', 'wp-user-avatar') ?></th> |
| 203 | </tr> |
| 204 | </thead> |
| 205 | <tbody> |
| 206 | <?php $index = 0; ?> |
| 207 | <?php foreach ($downloads['files'] as $file_url => $file_name) : ?> |
| 208 | <?php $download_link = DownloadService::init()->get_download_file_url( |
| 209 | $order->order_key, |
| 210 | $index, |
| 211 | $downloads['download_expiry'] |
| 212 | ); ?> |
| 213 | <tr> |
| 214 | <td><?= $file_name ?></td> |
| 215 | <td><?php echo DownloadService::init()->get_downloads_remaining( |
| 216 | $order->get_id(), |
| 217 | $plan->get_id(), |
| 218 | $file_url |
| 219 | ) ?></td> |
| 220 | <td> |
| 221 | <a class="ppress-myac-action" href="<?php echo esc_url($download_link) ?>"><?php esc_html_e('Download', 'wp-user-avatar'); ?></a> |
| 222 | </td> |
| 223 | </tr> |
| 224 | <?php $index++; ?> |
| 225 | <?php endforeach; ?> |
| 226 | </tbody> |
| 227 | </table> |
| 228 | </div> |
| 229 | </div> |
| 230 | |
| 231 | <?php endif; ?> |
| 232 | <?php endif; ?> |
| 233 | <?php endif; ?> |
| 234 | </div> |
| 235 | <?php |
| 236 | |
| 237 | do_action('ppress_myaccount_view_order_details', $order); |