PluginProbe
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses / 4.4.8
LearnPress – WordPress LMS Plugin for Create and Sell Online Courses v4.4.8
4.4.8 4.4.7 4.4.6 4.4.5 4.4.4 4.4.3 4.4.2 4.4.1 4.4.0 4.3.9.1 4.3.9 4.3.8 4.3.7 4.1.6.9 4.1.6.9.1 4.1.6.9.2 4.1.6.9.3 4.1.6.9.4 4.1.7 4.1.7.1 4.1.7.2 4.1.7.3 4.1.7.3.1 4.1.7.3.2 4.2.0 All 139 releases
learnpress / templates / checkout / order-received.php

order-received.php in LearnPress – WordPress LMS Plugin for Create and Sell Online Courses 4.4.8, at templates/checkout/order-received.php

189 lines 5.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Template for displaying order detail.
4 *
5 * This template can be overridden by copying it to yourtheme/learnpress/checkout/order-received.php.
6 *
7 * @author ThimPress
8 * @package Learnpress/Templates
9 * @version 4.0.4
10 */
11
12 use LearnPress\Models\CourseModel;
13 use LearnPress\Models\UserItems\UserCourseModel;
14 use LearnPress\Models\UserModel;
15 use LearnPress\TemplateHooks\Course\SingleCourseTemplate;
16 use LearnPress\TemplateHooks\UserItem\UserCourseTemplate;
17
18 defined( 'ABSPATH' ) || exit();
19
20 $user_id = get_current_user_id();
21 $lp_profile = learn_press_get_profile( $user_id );
22 $userModel = UserModel::find( $user_id, true );
23 ?>
24 <div class="lp-content-area">
25 <?php
26 /**
27 * @var LP_Order $order_received
28 */
29 if ( ! isset( $order_received ) ) {
30 echo wp_sprintf(
31 '<p>%s</p>',
32 esc_html(
33 apply_filters(
34 'learn-press/order/received-invalid-order-message',
35 __( 'Invalid order.', 'learnpress' )
36 )
37 )
38 );
39
40 return;
41 }
42
43 echo wp_sprintf(
44 '<p>%s</p><p>%s</p>',
45 esc_html(
46 apply_filters(
47 'learn-press/order/received-order-message',
48 __( 'Thank you. Your order has been received.', 'learnpress' )
49 )
50 ),
51 sprintf(
52 __( 'Go to %1$s to continue browsing or go to %2$s', 'learnpress' ),
53 sprintf(
54 '<a href="%s">%s</a>',
55 esc_url( learn_press_get_page_link( 'courses' ) ),
56 esc_html__( 'Courses', 'learnpress' )
57 ),
58 sprintf(
59 '<a href="%s">%s</a>',
60 esc_url( $lp_profile->get_tab_link( 'orders' ) ),
61 esc_html__( 'My Orders', 'learnpress' )
62 )
63 )
64 );
65 do_action( 'learn-press/order/after-received-order-message', $order_received->get_id() );
66
67 ?>
68 <div class="lp-table-wrap">
69 <table class="order_details lp-list-table">
70 <?php if ( isset( $_GET['key'] ) && ! is_user_logged_in() ) : ?>
71 <tr class="order-key">
72 <th><?php esc_html_e( 'Order Key', 'learnpress' ); ?></th>
73 <td>
74 <?php echo esc_html( $_GET['key'] ); ?>
75 </td>
76 </tr>
77 <?php endif; ?>
78 <tr class="order">
79 <th><?php esc_html_e( 'Order Number', 'learnpress' ); ?></th>
80 <td>
81 <?php echo esc_html( $order_received->get_order_number() ); ?>
82 </td>
83 </tr>
84 <tr class="status">
85 <th><?php esc_html_e( 'Status', 'learnpress' ); ?></th>
86 <td>
87 <?php
88 $status = $order_received->get_status();
89 echo ucfirst( $order_received::get_status_label( $status ) );
90 ?>
91 </td>
92 </tr>
93 <tr class="item">
94 <th><?php esc_html_e( 'Item', 'learnpress' ); ?></th>
95 <td>
96 <?php
97 $links = array();
98 $items = $order_received->get_items();
99 $count = count( $items );
100
101 foreach ( $items as $item ) {
102 if ( empty( $item['course_id'] ) || get_post_type( $item['course_id'] ) !== LP_COURSE_CPT ) {
103 $links[] = apply_filters(
104 'learn-press/order-item-not-course-id',
105 __( 'The course does not exist', 'learnpress' ),
106 $item
107 );
108 } else {
109 $course_id = $item['course_id'];
110 $courseModel = CourseModel::find( $course_id, true );
111 $button_course = '';
112 $userCourseModel = UserCourseModel::find( $user_id, $course_id, true );
113 if ( $userCourseModel && $userModel ) {
114 // For enrolled or purchased course.
115 $userCourseTemplate = UserCourseTemplate::instance();
116 $singleCourseTemplate = SingleCourseTemplate::instance();
117
118 // Load js button course.
119 wp_enqueue_script( 'lp-single-course' );
120
121 if ( $userCourseModel->has_enrolled() ) {
122 $button_course = $userCourseTemplate->html_btn_continue( $userCourseModel );
123 } elseif ( $userCourseModel->has_purchased() ) {
124 $button_course = $singleCourseTemplate->html_btn_enroll_course( $courseModel, $userModel );
125 }
126 }
127
128 $link = sprintf(
129 '<a href="%s">%s (#%s)</a> %s',
130 get_the_permalink( $item['course_id'] ),
131 get_the_title( $item['course_id'] ),
132 $item['course_id'],
133 $button_course
134 );
135
136 if ( $count > 1 ) {
137 $link = sprintf( '<li>%s</li>', $link );
138 }
139 $links[] = apply_filters( 'learn-press/order-received-item-link', $link, $item );
140 }
141 }
142
143 if ( $count > 1 ) {
144 echo sprintf( '<ol>%s</ol>', join( '', $links ) );
145 } elseif ( 1 == $count ) {
146 echo implode( '', $links );
147 } else {
148 echo esc_html__( '(No item)', 'learnpress' );
149 }
150 ?>
151 </td>
152 </tr>
153 <tr class="date">
154 <th><?php esc_html_e( 'Date', 'learnpress' ); ?></th>
155 <td>
156 <?php
157 echo wp_kses_post(
158 date_i18n(
159 get_option( 'date_format' ),
160 strtotime( $order_received->get_order_date() )
161 )
162 );
163 ?>
164 </td>
165 </tr>
166 <tr class="total">
167 <th><?php esc_html_e( 'Total', 'learnpress' ); ?></th>
168 <td>
169 <?php echo wp_kses_post( $order_received->get_formatted_order_total() ); ?>
170 </td>
171 </tr>
172 <?php
173 $method_title = $order_received->get_payment_method_title();
174 if ( $method_title ) :
175 ?>
176 <tr class="method">
177 <th><?php esc_html_e( 'Payment Method', 'learnpress' ); ?></th>
178 <td>
179 <?php echo esc_html( $method_title ); ?>
180 </td>
181 </tr>
182 <?php endif; ?>
183 <?php do_action( 'learn-press/order/received/items-table', $order_received ); ?>
184 </table>
185 </div>
186
187 <?php do_action( 'learn-press/order/received', $order_received ); ?>
188 </div>
189