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.2 3.5.0 3.6.0 3.6.1 3.6.2 3.6.3 3.6.4 3.7.0 3.7.1 3.7.2 3.7.3 3.7.4 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 3.9.1 3.9.10 3.9.2 3.9.3 3.9.4 3.9.5 3.9.6 3.9.7 3.9.8 3.9.9
tutor / templates / dashboard / purchase_history.php
tutor / templates / dashboard Last commit date
announcements 4 years ago assignments 4 years ago elements 4 years ago enrolled-courses 4 years ago instructor 3 years ago my-courses 4 years ago my-quiz-attempts 4 years ago notifications 4 years ago question-answer 4 years ago quiz-attempts 4 years ago reviews 4 years ago settings 3 years ago withdraw-method-fields 4 years ago announcements.php 4 years ago assignments.php 4 years ago create-course.php 3 years ago dashboard.php 3 years ago enrolled-courses.php 4 years ago index.php 4 years ago logged-in.php 4 years ago my-courses.php 4 years ago my-profile.php 4 years ago my-quiz-attempts.php 4 years ago purchase_history.php 4 years ago question-answer.php 4 years ago quiz-attempts.php 4 years ago registration.php 4 years ago reviews.php 4 years ago settings.php 4 years ago wishlist.php 4 years ago withdraw.php 3 years ago
purchase_history.php
200 lines
1 <?php
2 /**
3 * Purchase history
4 * @package TutorLMS/Templates
5 * @version 1.4.3
6 */
7
8 defined( 'ABSPATH' ) || exit;
9
10 //global variables
11 $user_id = get_current_user_id();
12 $time_period = $active = isset( $_GET['period'] ) ? $_GET['period'] : '';
13 $start_date = isset( $_GET['start_date']) ? sanitize_text_field( $_GET['start_date'] ) : '';
14 $end_date = isset( $_GET['end_date']) ? sanitize_text_field( $_GET['end_date'] ) : '';
15
16 $paged = ( isset( $_GET['current_page'] ) && is_numeric( $_GET['current_page'] ) && $_GET['current_page'] >= 1 ) ? $_GET['current_page'] : 1;
17 $per_page = tutor_utils()->get_option( 'pagination_per_page', 10 );
18 $offset = ( $per_page * $paged ) - $per_page;
19 if ( '' !== $start_date ) {
20 $start_date = tutor_get_formated_date( 'Y-m-d', $start_date );
21 }
22
23 if ( '' !== $end_date ) {
24 $end_date = tutor_get_formated_date( 'Y-m-d', $end_date );
25 }
26
27 /**
28 * Prepare filter period buttons
29 *
30 * Array structure is required as below
31 *
32 * @since 2.0.0
33 */
34 $filter_period = array(
35 array(
36 'url' => esc_url( tutor_utils()->tutor_dashboard_url() . 'purchase_history?period=today' ),
37 'title' => __( 'Today', 'tutor' ),
38 'type' => 'today'
39 ),
40 array(
41 'url' => esc_url( tutor_utils()->tutor_dashboard_url() . 'purchase_history?period=monthly' ),
42 'title' => __( 'Monthly', 'tutor' ),
43 'type' => 'monthly'
44 ),
45 array(
46 'url' => esc_url( tutor_utils()->tutor_dashboard_url() . 'purchase_history?period=yearly' ),
47 'title' => __( 'Yearly', 'tutor' ),
48 'type' => 'yearly'
49 ),
50 );
51
52 /**
53 * Calendar date buttons
54 *
55 * Array structure is required as below
56 *
57 * @since 2.0.0
58 */
59
60 $filter_period_calendar = array(
61 'filter_period' => $filter_period,
62 'filter_calendar' => true
63 );
64
65 $filter_period_calendar_template = tutor()->path . 'views/elements/purchase-history-filter.php';
66 tutor_load_template_from_custom_path( $filter_period_calendar_template, $filter_period_calendar );
67
68 $orders = tutor_utils()->get_orders_by_user_id( $user_id, $time_period, $start_date, $end_date, $offset, $per_page );
69 $total_orders = tutor_utils()->get_total_orders_by_user_id( $user_id, $time_period, $start_date, $end_date );
70 $monetize_by = tutor_utils()->get_option( 'monetize_by' );
71
72 ?>
73
74 <div class="tutor-purchase-history">
75 <?php if ( tutor_utils()->count( $orders ) ) : ?>
76 <div class="tutor-fs-5 tutor-fw-medium tutor-color-black tutor-mb-24"><?php esc_html_e( 'Order History', 'tutor' ); ?></div>
77 <div class="tutor-table-responsive">
78 <table class="tutor-table">
79 <thead>
80 <th width="10%">
81 <?php esc_html_e( 'Order ID', 'tutor' ); ?>
82 </th>
83 <th width="45%">
84 <?php esc_html_e( 'Course Name', 'tutor' ); ?>
85 </th>
86 <th>
87 <?php esc_html_e( 'Date', 'tutor' ); ?>
88 </th>
89 <th>
90 <?php esc_html_e( 'Price', 'tutor' ); ?>
91 </th>
92 <th>
93 <?php esc_html_e( 'Status', 'tutor' ); ?>
94 </th>
95 <th></th>
96 </thead>
97
98 <tbody>
99 <?php foreach ( $orders as $order ) : ?>
100 <?php
101 if ( $monetize_by === 'wc' ) {
102 $wc_order = wc_get_order( $order->ID );
103 $price = tutor_utils()->tutor_price( $wc_order->get_total() );
104 $raw_price = $wc_order->get_total();
105 $status = $order->post_status;
106 $badge_class = 'primary';
107 $order_status_text = '';
108
109 switch ( $status ) {
110 case 'wc-completed' === $status:
111 $badge_class = 'success';
112 $order_status_text = __( 'Completed', 'tutor' );
113 break;
114 case 'wc-processing' === $status:
115 $badge_class = 'warning';
116 $order_status_text = __( 'Processing', 'tutor' );
117 break;
118 case 'wc-on-hold' === $status:
119 $badge_class = 'warning';
120 $order_status_text = __( 'On Hold', 'tutor' );
121 break;
122 case 'wc-refunded' === $status:
123 $badge_class = 'danger';
124 $order_status_text = __( 'Processing', 'tutor' );
125 break;
126 case 'wc-cancelled' === $status:
127 $badge_class = 'danger';
128 $order_status_text = __( 'Cancelled', 'tutor' );
129 break;
130 case 'wc-pending' === $status:
131 $badge_class = 'warning';
132 $order_status_text = __( 'Pending', 'tutor' );
133 break;
134 }
135 } else if ( $monetize_by === 'edd' ) {
136 $edd_order = edd_get_payment( $order->ID );
137 $price = edd_currency_filter( edd_format_amount( $edd_order->total ), edd_get_payment_currency_code( $order->ID ) );
138 $raw_price = $edd_order->total;
139 $status = $edd_order->status_nicename;
140 $badge_class = 'primary';
141 $order_status_text = $status;
142 }
143 ?>
144 <tr>
145 <td>
146 #<?php esc_html_e( $order->ID ); ?>
147 </td>
148
149 <td>
150 <?php
151 $courses = tutor_utils()->get_course_enrolled_ids_by_order_id( $order->ID );
152 if ( tutor_utils()->count( $courses ) ) {
153 foreach ( $courses as $course ) {
154 echo '<div>' . esc_html( get_the_title( $course['course_id'] ) ) . '</div>';
155 }
156 }
157 ?>
158 </td>
159
160 <td>
161 <?php echo date_i18n( get_option( 'date_format' ), strtotime( $order->post_date ) ); ?>
162 </td>
163
164 <td>
165 <?php echo wp_kses_post( $price ); ?>
166 </td>
167
168 <td>
169 <span class="tutor-badge-label label-<?php esc_attr_e( $badge_class ); ?> tutor-m-4"><?php esc_html_e( $order_status_text ); ?></span>
170 </td>
171
172 <td>
173 <a href="javascript:;" class="tutor-export-purchase-history tutor-iconic-btn tutor-iconic-btn-secondary" data-order="<?php echo esc_attr( $order->ID ); ?>" data-course-name="<?php echo esc_attr( get_the_title( $course['course_id'] ) ); ?>" data-price="<?php echo esc_attr( $raw_price ); ?>" data-date="<?php echo esc_attr( date_i18n( get_option( 'date_format' ), strtotime( $order->post_date ) ) ); ?>" data-status="<?php echo esc_attr( $order_status_text ); ?>">
174 <span class="tutor-icon-receipt-line" area-hidden="true"></span>
175 </a>
176 </td>
177 </tr>
178 <?php endforeach; ?>
179 </tbody>
180 </table>
181 </div>
182
183 <?php
184 $pagination_data = array(
185 'total_items' => ! empty( $total_orders ) ? count( $total_orders ) : 0,
186 'per_page' => $per_page,
187 'paged' => $paged,
188 );
189
190 $total_page = ceil($pagination_data['total_items'] / $pagination_data['per_page']);
191
192 if( $total_page > 1 ) {
193 $pagination_template = tutor()->path . 'templates/dashboard/elements/pagination.php';
194 tutor_load_template_from_custom_path( $pagination_template, $pagination_data );
195 }
196 ?>
197 <?php else : ?>
198 <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?>
199 <?php endif; ?>
200 </div>