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