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