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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 2 years ago elements 1 year ago enrolled-courses 3 years ago instructor 2 years ago my-courses 3 years ago my-quiz-attempts 3 years ago notifications 3 years ago question-answer 2 years ago quiz-attempts 3 years ago reviews 3 years ago settings 1 year ago withdraw-method-fields 3 years ago announcements.php 1 year ago assignments.php 1 year ago create-course.php 1 year ago dashboard.php 1 year ago enrolled-courses.php 1 year ago index.php 3 years ago logged-in.php 3 years ago my-courses.php 1 year ago my-profile.php 3 years ago my-quiz-attempts.php 3 years ago purchase_history.php 1 year ago question-answer.php 2 years ago quiz-attempts.php 1 year ago registration.php 2 years ago reviews.php 3 years ago settings.php 3 years ago wishlist.php 1 year ago withdraw.php 1 year ago
purchase_history.php
309 lines
1 <?php
2 /**
3 * Purchase history
4 *
5 * @package Tutor\Templates
6 * @subpackage Dashboard
7 * @author Themeum <support@themeum.com>
8 * @link https://themeum.com
9 * @since 1.4.3
10 */
11
12 defined( 'ABSPATH' ) || exit;
13
14 use Tutor\Ecommerce\Ecommerce;
15 use Tutor\Helpers\DateTimeHelper;
16 use TUTOR\Input;
17 use Tutor\Models\OrderModel;
18
19 // Global variables.
20 $user_id = get_current_user_id();
21 $active = Input::get( 'period', '' );
22 $time_period = $active;
23 $start_date = Input::get( 'start_date', '' );
24 $end_date = Input::get( 'end_date', '' );
25
26 $paged = Input::get( 'current_page', 1, Input::TYPE_INT );
27 $per_page = tutor_utils()->get_option( 'pagination_per_page', 10 );
28 $offset = ( $per_page * $paged ) - $per_page;
29 if ( '' !== $start_date ) {
30 $start_date = tutor_get_formated_date( 'Y-m-d', $start_date );
31 }
32
33 if ( '' !== $end_date ) {
34 $end_date = tutor_get_formated_date( 'Y-m-d', $end_date );
35 }
36
37 /**
38 * Prepare filter period buttons
39 *
40 * Array structure is required as below
41 *
42 * @since 2.0.0
43 */
44 $filter_period = array(
45 array(
46 'url' => esc_url( tutor_utils()->tutor_dashboard_url() . 'purchase_history?period=today' ),
47 'title' => __( 'Today', 'tutor' ),
48 'type' => 'today',
49 ),
50 array(
51 'url' => esc_url( tutor_utils()->tutor_dashboard_url() . 'purchase_history?period=monthly' ),
52 'title' => __( 'Monthly', 'tutor' ),
53 'type' => 'monthly',
54 ),
55 array(
56 'url' => esc_url( tutor_utils()->tutor_dashboard_url() . 'purchase_history?period=yearly' ),
57 'title' => __( 'Yearly', 'tutor' ),
58 'type' => 'yearly',
59 ),
60 );
61
62 /**
63 * Calendar date buttons
64 *
65 * Array structure is required as below
66 *
67 * @since 2.0.0
68 */
69
70 $filter_period_calendar = array(
71 'filter_period' => $filter_period,
72 'filter_calendar' => true,
73 );
74
75 ?>
76 <div class="tutor-fs-5 tutor-fw-medium tutor-color-black tutor-mb-24">
77 <?php esc_html_e( 'Order History', 'tutor' ); ?>
78 </div>
79 <?php
80
81 $filter_period_calendar_template = tutor()->path . 'views/elements/purchase-history-filter.php';
82 tutor_load_template_from_custom_path( $filter_period_calendar_template, $filter_period_calendar );
83
84 $orders = tutor_utils()->get_orders_by_user_id( $user_id, $time_period, $start_date, $end_date, $offset, $per_page );
85 $total_orders = tutor_utils()->get_total_orders_by_user_id( $user_id, $time_period, $start_date, $end_date );
86 $total_orders = ! empty( $total_orders ) ? count( $total_orders ) : 0;
87
88 $monetize_by = tutor_utils()->get_option( 'monetize_by' );
89 if ( Ecommerce::MONETIZE_BY === $monetize_by ) {
90 $response = ( new OrderModel() )->get_user_orders( $time_period, $start_date, $end_date, $user_id, $per_page, $offset );
91 $orders = $response['results'];
92 $total_orders = $response['total_count'];
93 }
94 ?>
95
96 <div class="tutor-purchase-history">
97 <?php if ( tutor_utils()->count( $orders ) ) : ?>
98 <div class="tutor-fs-5 tutor-fw-medium tutor-color-black tutor-mb-24"><?php esc_html_e( 'Order History', 'tutor' ); ?></div>
99 <div class="tutor-table-responsive">
100 <table class="tutor-table">
101 <thead>
102 <th width="8%">
103 <?php esc_html_e( 'Order ID', 'tutor' ); ?>
104 </th>
105 <th width="30%">
106 <?php esc_html_e( 'Course Name', 'tutor' ); ?>
107 </th>
108 <th>
109 <?php esc_html_e( 'Date', 'tutor' ); ?>
110 </th>
111 <th>
112 <?php esc_html_e( 'Price', 'tutor' ); ?>
113 </th>
114 <th>
115 <?php esc_html_e( 'Status', 'tutor' ); ?>
116 </th>
117 <?php if ( Ecommerce::MONETIZE_BY === $monetize_by ) : ?>
118 <th>
119 <?php esc_html_e( 'Payment Method', 'tutor' ); ?>
120 </th>
121 <?php endif; ?>
122 <th></th>
123 </thead>
124 <?php if ( Ecommerce::MONETIZE_BY === $monetize_by ) : ?>
125 <tbody>
126 <?php
127 if ( is_array( $orders ) && count( $orders ) ) :
128 ?>
129 <?php
130 foreach ( $orders as $order ) :
131 ?>
132 <tr>
133 <td>
134 <div class="tutor-fs-7">
135 #<?php echo esc_html( $order->id ); ?>
136 </div>
137 </td>
138 <td>
139 <div class="tutor-fs-7">
140 <?php
141 $items = ( new OrderModel() )->get_order_items_by_id( $order->id );
142 foreach ( $items as $item ) {
143 $course_id = $item->id;
144 if ( OrderModel::TYPE_SUBSCRIPTION ) {
145 $course_id = apply_filters( 'tutor_subscription_course_by_plan', $item->id, $order );
146 }
147 ?>
148 <li>
149 <?php echo esc_html( get_the_title( $course_id ) ); ?>
150 </li>
151 <?php
152 }
153 ?>
154 </div>
155 </td>
156 <td>
157 <div class="tutor-fs-7 tutor-text-nowrap">
158 <?php echo esc_html( DateTimeHelper::get_gmt_to_user_timezone_date( $order->created_at_gmt ) ); ?>
159 </div>
160 </td>
161 <td>
162 <div class="tutor-fs-7">
163 <?php echo esc_html( tutor_get_formatted_price( $order->total_price ) ); ?>
164 </div>
165 </td>
166 <td>
167 <?php
168 echo wp_kses_post( tutor_utils()->translate_dynamic_text( $order->order_status, true ) );
169 ?>
170 </td>
171 <td>
172 <div class="tutor-fs-7">
173 <?php echo esc_html( Ecommerce::get_payment_method_label( $order->payment_method ?? '' ) ); ?>
174 </div>
175 </td>
176 <td>
177 <div class="tutor-d-flex tutor-gap-1 tutor-justify-end">
178 <?php
179 OrderModel::render_pay_button( $order );
180 do_action( 'tutor_dashboard_invoice_button', $order );
181 ?>
182 </div>
183 </td>
184 </tr>
185 <?php endforeach; ?>
186 <?php else : ?>
187 <?php tutor_utils()->tutor_empty_state(); ?>
188 <?php endif; ?>
189 </tbody>
190 <?php else : ?>
191 <tbody>
192 <?php foreach ( $orders as $order ) : ?>
193 <?php
194 if ( 'wc' === $monetize_by ) {
195 $wc_order = wc_get_order( $order->ID );
196 $price = tutor_utils()->tutor_price( $wc_order->get_total() );
197 $raw_price = $wc_order->get_total();
198 $status = $order->post_status;
199 $badge_class = 'primary';
200 $order_status_text = '';
201
202 switch ( $status ) {
203 case 'wc-completed' === $status:
204 $badge_class = 'success';
205 $order_status_text = __( 'Completed', 'tutor' );
206 break;
207 case 'wc-processing' === $status:
208 $badge_class = 'warning';
209 $order_status_text = __( 'Processing', 'tutor' );
210 break;
211 case 'wc-on-hold' === $status:
212 $badge_class = 'warning';
213 $order_status_text = __( 'On Hold', 'tutor' );
214 break;
215 case 'wc-refunded' === $status:
216 $badge_class = 'danger';
217 $order_status_text = __( 'Processing', 'tutor' );
218 break;
219 case 'wc-cancelled' === $status:
220 $badge_class = 'danger';
221 $order_status_text = __( 'Cancelled', 'tutor' );
222 break;
223 case 'wc-pending' === $status:
224 $badge_class = 'warning';
225 $order_status_text = __( 'Pending', 'tutor' );
226 break;
227 }
228 } elseif ( 'edd' === $monetize_by ) {
229 $edd_order = edd_get_payment( $order->ID );
230 $price = edd_currency_filter( edd_format_amount( $edd_order->total ), edd_get_payment_currency_code( $order->ID ) );
231 $raw_price = $edd_order->total;
232 $status = $edd_order->status_nicename;
233 $badge_class = 'primary';
234 $order_status_text = $status;
235 }
236 ?>
237 <tr>
238 <td>
239 #<?php echo esc_html( $order->ID ); ?>
240 </td>
241
242 <td>
243 <?php
244 $courses = tutor_utils()->get_course_enrolled_ids_by_order_id( $order->ID );
245 if ( tutor_utils()->count( $courses ) ) {
246 foreach ( $courses as $course ) {
247 echo '<div>' . esc_html( get_the_title( $course['course_id'] ) ) . '</div>';
248 }
249 }
250 ?>
251 </td>
252
253 <td>
254 <?php echo esc_html( date_i18n( get_option( 'date_format' ), strtotime( $order->post_date ) ) ); ?>
255 </td>
256
257 <td>
258 <?php echo wp_kses_post( $price ); ?>
259 </td>
260
261 <td>
262 <span class="tutor-badge-label label-<?php echo esc_attr( $badge_class ); ?> tutor-m-4"><?php echo esc_html( $order_status_text ); ?></span>
263 </td>
264 <td>
265 <?php
266 $pay_now_url = '';
267 if ( 'wc' === $monetize_by ) {
268 $wc_order = wc_get_order( $order->ID );
269 $pay_now_url = esc_url( $wc_order->get_checkout_payment_url() );
270 }
271 ?>
272 <div class="tutor-order-history-actions">
273 <?php if ( 'wc-pending' === $status ) : ?>
274 <a href="<?php echo esc_url( $pay_now_url ); ?>"
275 class="tutor-btn tutor-btn-outline-primary tutor-btn-sm tutor-mr-8">
276 <?php esc_html_e( 'Pay', 'tutor-pro' ); ?>
277 </a>
278 <?php endif; ?>
279 <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 ); ?>">
280 <span class="tutor-icon-receipt-line" area-hidden="true"></span>
281 </a>
282 </div>
283 </td>
284 </tr>
285 <?php endforeach; ?>
286 </tbody>
287 <?php endif; ?>
288 </table>
289 </div>
290
291 <?php
292 $pagination_data = array(
293 'total_items' => $total_orders,
294 'per_page' => $per_page,
295 'paged' => $paged,
296 );
297
298 $total_page = ceil( $pagination_data['total_items'] / $pagination_data['per_page'] );
299
300 if ( $total_page > 1 ) {
301 $pagination_template = tutor()->path . 'templates/dashboard/elements/pagination.php';
302 tutor_load_template_from_custom_path( $pagination_template, $pagination_data );
303 }
304 ?>
305 <?php else : ?>
306 <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?>
307 <?php endif; ?>
308 </div>
309