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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 1 year ago assignments 8 months ago elements 1 year ago enrolled-courses 3 years ago instructor 2 years ago my-courses 1 year ago my-quiz-attempts 3 years ago notifications 3 years ago question-answer 1 year 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 11 months ago create-course.php 1 year ago dashboard.php 8 months ago enrolled-courses.php 8 months ago index.php 3 years ago logged-in.php 3 years ago my-courses.php 8 months ago my-profile.php 9 months ago my-quiz-attempts.php 3 years ago purchase_history.php 10 months ago question-answer.php 11 months ago quiz-attempts.php 1 year ago registration.php 2 years ago reviews.php 3 years ago settings.php 1 year ago wishlist.php 1 year ago withdraw.php 1 year ago
purchase_history.php
318 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\Input;
15 use Tutor\Models\OrderModel;
16 use Tutor\Ecommerce\Ecommerce;
17 use Tutor\Helpers\DateTimeHelper;
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 );//phpcs:ignore
27 $per_page = tutor_utils()->get_option( 'pagination_per_page', 10 );//phpcs:ignore
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( '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 ) : //phpcs:ignore WordPress.WP.GlobalVariablesOverride.Prohibited
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; // For single order course, bundle.
144 $object_title = get_the_title( $course_id );
145 if ( OrderModel::TYPE_SINGLE_ORDER !== $order->order_type ) {
146 $object_id = apply_filters( 'tutor_subscription_course_by_plan', $item->id, $order );
147 $plan_info = apply_filters( 'tutor_get_plan_info', null, $item->id );
148 if ( $plan_info && isset( $plan_info->is_membership_plan ) && $plan_info->is_membership_plan ) {
149 $object_title = $plan_info->plan_name;
150 } else {
151 $object_title = get_the_title( $object_id );
152 }
153 }
154
155 ?>
156 <li>
157 <?php echo esc_html( $object_title ); ?>
158 </li>
159 <?php
160 }
161 ?>
162 </div>
163 </td>
164 <td>
165 <div class="tutor-fs-7 tutor-text-nowrap">
166 <?php echo esc_html( DateTimeHelper::get_gmt_to_user_timezone_date( $order->created_at_gmt ) ); ?>
167 </div>
168 </td>
169 <td>
170 <div class="tutor-fs-7">
171 <?php echo esc_html( tutor_get_formatted_price( $order->total_price ) ); ?>
172 </div>
173 </td>
174 <td>
175 <?php
176 echo wp_kses_post( tutor_utils()->translate_dynamic_text( $order->order_status, true ) );
177 ?>
178 </td>
179 <td>
180 <div class="tutor-fs-7">
181 <?php echo esc_html( Ecommerce::get_payment_method_label( $order->payment_method ?? '' ) ); ?>
182 </div>
183 </td>
184 <td>
185 <div class="tutor-d-flex tutor-gap-1 tutor-justify-end">
186 <?php
187 OrderModel::render_pay_button( $order );
188 do_action( 'tutor_dashboard_invoice_button', $order );
189 ?>
190 </div>
191 </td>
192 </tr>
193 <?php endforeach; ?>
194 <?php else : ?>
195 <?php tutor_utils()->tutor_empty_state(); ?>
196 <?php endif; ?>
197 </tbody>
198 <?php else : ?>
199 <tbody>
200 <?php foreach ( $orders as $order ) : //phpcs:ignore ?>
201 <?php
202 if ( 'wc' === $monetize_by ) {
203 $wc_order = wc_get_order( $order->ID );
204 $price = tutor_utils()->tutor_price( $wc_order->get_total() );
205 $raw_price = $wc_order->get_total();
206 $status = $order->post_status;//phpcs:ignore
207 $badge_class = 'primary';
208 $order_status_text = '';
209
210 switch ( $status ) {
211 case 'wc-completed' === $status:
212 $badge_class = 'success';
213 $order_status_text = __( 'Completed', 'tutor' );
214 break;
215 case 'wc-processing' === $status:
216 $badge_class = 'warning';
217 $order_status_text = __( 'Processing', 'tutor' );
218 break;
219 case 'wc-on-hold' === $status:
220 $badge_class = 'warning';
221 $order_status_text = __( 'On Hold', 'tutor' );
222 break;
223 case 'wc-refunded' === $status:
224 $badge_class = 'danger';
225 $order_status_text = __( 'Refunded', 'tutor' );
226 break;
227 case 'wc-cancelled' === $status:
228 $badge_class = 'danger';
229 $order_status_text = __( 'Cancelled', 'tutor' );
230 break;
231 case 'wc-pending' === $status:
232 $badge_class = 'warning';
233 $order_status_text = __( 'Pending', 'tutor' );
234 break;
235 }
236 } elseif ( 'edd' === $monetize_by ) {
237 $edd_order = edd_get_payment( $order->ID );
238 $price = edd_currency_filter( edd_format_amount( $edd_order->total ), edd_get_payment_currency_code( $order->ID ) );
239 $raw_price = $edd_order->total;
240 $status = $edd_order->status_nicename;//phpcs:ignore
241 $badge_class = 'primary';
242 $order_status_text = $status;
243 }
244 ?>
245 <tr>
246 <td>
247 #<?php echo esc_html( $order->ID ); ?>
248 </td>
249
250 <td>
251 <?php
252 $courses = tutor_utils()->get_course_enrolled_ids_by_order_id( $order->ID );
253 if ( tutor_utils()->count( $courses ) ) {
254 foreach ( $courses as $course ) {
255 echo '<div>' . esc_html( get_the_title( $course['course_id'] ) ) . '</div>';
256 }
257 }
258 ?>
259 </td>
260
261 <td>
262 <?php echo esc_html( date_i18n( get_option( 'date_format' ), strtotime( $order->post_date ) ) ); ?>
263 </td>
264
265 <td>
266 <?php echo wp_kses_post( $price ); ?>
267 </td>
268
269 <td>
270 <span class="tutor-badge-label label-<?php echo esc_attr( $badge_class ); ?> tutor-m-4"><?php echo esc_html( $order_status_text ); ?></span>
271 </td>
272 <td>
273 <?php
274 $pay_now_url = '';
275 if ( 'wc' === $monetize_by ) {
276 $wc_order = wc_get_order( $order->ID );
277 $pay_now_url = esc_url( $wc_order->get_checkout_payment_url() );
278 }
279 ?>
280 <div class="tutor-order-history-actions">
281 <?php if ( 'wc-pending' === $status ) : ?>
282 <a href="<?php echo esc_url( $pay_now_url ); ?>"
283 class="tutor-btn tutor-btn-outline-primary tutor-btn-sm tutor-mr-8">
284 <?php esc_html_e( 'Pay', 'tutor' ); ?>
285 </a>
286 <?php endif; ?>
287 <?php $courses_data_string = implode( ',', array_map( fn( $course_data ) => get_the_title( $course_data['course_id'] ), $courses ) ); ?>
288 <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( '"' . $courses_data_string . '"' ); ?>" 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 ); ?>">
289 <span class="tutor-icon-receipt-line" area-hidden="true"></span>
290 </a>
291 </div>
292 </td>
293 </tr>
294 <?php endforeach; ?>
295 </tbody>
296 <?php endif; ?>
297 </table>
298 </div>
299
300 <?php
301 $pagination_data = array(
302 'total_items' => $total_orders,
303 'per_page' => $per_page,
304 'paged' => $paged,
305 );
306
307 $total_page = ceil( $pagination_data['total_items'] / $pagination_data['per_page'] );
308
309 if ( $total_page > 1 ) {
310 $pagination_template = tutor()->path . 'templates/dashboard/elements/pagination.php';
311 tutor_load_template_from_custom_path( $pagination_template, $pagination_data );
312 }
313 ?>
314 <?php else : ?>
315 <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?>
316 <?php endif; ?>
317 </div>
318