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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 3 years ago instructor 3 years ago my-courses 3 years ago my-quiz-attempts 3 years ago notifications 3 years ago question-answer 3 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 3 years ago question-answer.php 3 years ago quiz-attempts.php 3 years ago registration.php 3 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
223 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 $filter_period_calendar_template = tutor()->path . 'views/elements/purchase-history-filter.php';
73 tutor_load_template_from_custom_path( $filter_period_calendar_template, $filter_period_calendar );
74
75 $orders = tutor_utils()->get_orders_by_user_id( $user_id, $time_period, $start_date, $end_date, $offset, $per_page );
76 $total_orders = tutor_utils()->get_total_orders_by_user_id( $user_id, $time_period, $start_date, $end_date );
77 $monetize_by = tutor_utils()->get_option( 'monetize_by' );
78
79 ?>
80
81 <div class="tutor-purchase-history">
82 <?php if ( tutor_utils()->count( $orders ) ) : ?>
83 <div class="tutor-fs-5 tutor-fw-medium tutor-color-black tutor-mb-24"><?php esc_html_e( 'Order History', 'tutor' ); ?></div>
84 <div class="tutor-table-responsive">
85 <table class="tutor-table">
86 <thead>
87 <th width="10%">
88 <?php esc_html_e( 'Order ID', 'tutor' ); ?>
89 </th>
90 <th width="40%">
91 <?php esc_html_e( 'Course Name', 'tutor' ); ?>
92 </th>
93 <th>
94 <?php esc_html_e( 'Date', 'tutor' ); ?>
95 </th>
96 <th>
97 <?php esc_html_e( 'Price', 'tutor' ); ?>
98 </th>
99 <th>
100 <?php esc_html_e( 'Status', 'tutor' ); ?>
101 </th>
102 <th></th>
103 </thead>
104
105 <tbody>
106 <?php foreach ( $orders as $order ) : ?>
107 <?php
108 if ( 'wc' === $monetize_by ) {
109 $wc_order = wc_get_order( $order->ID );
110 $price = tutor_utils()->tutor_price( $wc_order->get_total() );
111 $raw_price = $wc_order->get_total();
112 $status = $order->post_status;
113 $badge_class = 'primary';
114 $order_status_text = '';
115
116 switch ( $status ) {
117 case 'wc-completed' === $status:
118 $badge_class = 'success';
119 $order_status_text = __( 'Completed', 'tutor' );
120 break;
121 case 'wc-processing' === $status:
122 $badge_class = 'warning';
123 $order_status_text = __( 'Processing', 'tutor' );
124 break;
125 case 'wc-on-hold' === $status:
126 $badge_class = 'warning';
127 $order_status_text = __( 'On Hold', 'tutor' );
128 break;
129 case 'wc-refunded' === $status:
130 $badge_class = 'danger';
131 $order_status_text = __( 'Processing', 'tutor' );
132 break;
133 case 'wc-cancelled' === $status:
134 $badge_class = 'danger';
135 $order_status_text = __( 'Cancelled', 'tutor' );
136 break;
137 case 'wc-pending' === $status:
138 $badge_class = 'warning';
139 $order_status_text = __( 'Pending', 'tutor' );
140 break;
141 }
142 } elseif ( 'edd' === $monetize_by ) {
143 $edd_order = edd_get_payment( $order->ID );
144 $price = edd_currency_filter( edd_format_amount( $edd_order->total ), edd_get_payment_currency_code( $order->ID ) );
145 $raw_price = $edd_order->total;
146 $status = $edd_order->status_nicename;
147 $badge_class = 'primary';
148 $order_status_text = $status;
149 }
150 ?>
151 <tr>
152 <td>
153 #<?php echo esc_html( $order->ID ); ?>
154 </td>
155
156 <td>
157 <?php
158 $courses = tutor_utils()->get_course_enrolled_ids_by_order_id( $order->ID );
159 if ( tutor_utils()->count( $courses ) ) {
160 foreach ( $courses as $course ) {
161 echo '<div>' . esc_html( get_the_title( $course['course_id'] ) ) . '</div>';
162 }
163 }
164 ?>
165 </td>
166
167 <td>
168 <?php echo esc_html( date_i18n( get_option( 'date_format' ), strtotime( $order->post_date ) ) ); ?>
169 </td>
170
171 <td>
172 <?php echo wp_kses_post( $price ); ?>
173 </td>
174
175 <td>
176 <span class="tutor-badge-label label-<?php echo esc_attr( $badge_class ); ?> tutor-m-4"><?php echo esc_html( $order_status_text ); ?></span>
177 </td>
178
179 <td>
180 <?php
181 $pay_now_url = '';
182 if ( 'wc' === $monetize_by ) {
183 $wc_order = wc_get_order( $order->ID );
184 $pay_now_url = esc_url( $wc_order->get_checkout_payment_url() );
185 }
186 ?>
187 <div class="tutor-order-history-actions">
188 <?php if ( 'wc-pending' === $status ) : ?>
189 <a href="<?php echo esc_url( $pay_now_url ); ?>"
190 class="tutor-btn tutor-btn-outline-primary tutor-btn-sm tutor-mr-8">
191 <?php esc_html_e( 'Pay', 'tutor-pro' ); ?>
192 </a>
193 <?php endif; ?>
194 <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 ); ?>">
195 <span class="tutor-icon-receipt-line" area-hidden="true"></span>
196 </a>
197 </div>
198 </td>
199 </tr>
200 <?php endforeach; ?>
201 </tbody>
202 </table>
203 </div>
204
205 <?php
206 $pagination_data = array(
207 'total_items' => ! empty( $total_orders ) ? count( $total_orders ) : 0,
208 'per_page' => $per_page,
209 'paged' => $paged,
210 );
211
212 $total_page = ceil( $pagination_data['total_items'] / $pagination_data['per_page'] );
213
214 if ( $total_page > 1 ) {
215 $pagination_template = tutor()->path . 'templates/dashboard/elements/pagination.php';
216 tutor_load_template_from_custom_path( $pagination_template, $pagination_data );
217 }
218 ?>
219 <?php else : ?>
220 <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?>
221 <?php endif; ?>
222 </div>
223