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
← All changes | templates/checkout/order-received.php +188 -186 4.3.84.4.8 View file →
@@ -1,186 +1,188 @@
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 - <table class="order_details">
69 - <?php if ( isset( $_GET['key'] ) && ! is_user_logged_in() ) : ?>
70 - <tr class="order-key">
71 - <th><?php esc_html_e( 'Order Key', 'learnpress' ); ?></th>
72 - <td>
73 - <?php echo esc_html( $_GET['key'] ); ?>
74 - </td>
75 - </tr>
76 - <?php endif; ?>
77 - <tr class="order">
78 - <th><?php esc_html_e( 'Order Number', 'learnpress' ); ?></th>
79 - <td>
80 - <?php echo esc_html( $order_received->get_order_number() ); ?>
81 - </td>
82 - </tr>
83 - <tr class="status">
84 - <th><?php esc_html_e( 'Status', 'learnpress' ); ?></th>
85 - <td>
86 - <?php
87 - $status = $order_received->get_status();
88 - echo ucfirst( $order_received::get_status_label( $status ) );
89 - ?>
90 - </td>
91 - </tr>
92 - <tr class="item">
93 - <th><?php esc_html_e( 'Item', 'learnpress' ); ?></th>
94 - <td>
95 - <?php
96 - $links = array();
97 - $items = $order_received->get_items();
98 - $count = count( $items );
99 -
100 - foreach ( $items as $item ) {
101 - if ( empty( $item['course_id'] ) || get_post_type( $item['course_id'] ) !== LP_COURSE_CPT ) {
102 - $links[] = apply_filters(
103 - 'learn-press/order-item-not-course-id',
104 - __( 'The course does not exist', 'learnpress' ),
105 - $item
106 - );
107 - } else {
108 - $course_id = $item['course_id'];
109 - $courseModel = CourseModel::find( $course_id, true );
110 - $button_course = '';
111 - $userCourseModel = UserCourseModel::find( $user_id, $course_id, true );
112 - if ( $userCourseModel && $userModel ) {
113 - // For enrolled or purchased course.
114 - $userCourseTemplate = UserCourseTemplate::instance();
115 - $singleCourseTemplate = SingleCourseTemplate::instance();
116 -
117 - // Load js button course.
118 - wp_enqueue_script( 'lp-single-course' );
119 -
120 - if ( $userCourseModel->has_enrolled() ) {
121 - $button_course = $userCourseTemplate->html_btn_continue( $userCourseModel );
122 - } elseif ( $userCourseModel->has_purchased() ) {
123 - $button_course = $singleCourseTemplate->html_btn_enroll_course( $courseModel, $userModel );
124 - }
125 - }
126 -
127 - $link = sprintf(
128 - '<a href="%s">%s (#%s)</a> %s',
129 - get_the_permalink( $item['course_id'] ),
130 - get_the_title( $item['course_id'] ),
131 - $item['course_id'],
132 - $button_course
133 - );
134 -
135 - if ( $count > 1 ) {
136 - $link = sprintf( '<li>%s</li>', $link );
137 - }
138 - $links[] = apply_filters( 'learn-press/order-received-item-link', $link, $item );
139 - }
140 - }
141 -
142 - if ( $count > 1 ) {
143 - echo sprintf( '<ol>%s</ol>', join( '', $links ) );
144 - } elseif ( 1 == $count ) {
145 - echo implode( '', $links );
146 - } else {
147 - echo esc_html__( '(No item)', 'learnpress' );
148 - }
149 - ?>
150 - </td>
151 - </tr>
152 - <tr class="date">
153 - <th><?php esc_html_e( 'Date', 'learnpress' ); ?></th>
154 - <td>
155 - <?php
156 - echo wp_kses_post(
157 - date_i18n(
158 - get_option( 'date_format' ),
159 - strtotime( $order_received->get_order_date() )
160 - )
161 - );
162 - ?>
163 - </td>
164 - </tr>
165 - <tr class="total">
166 - <th><?php esc_html_e( 'Total', 'learnpress' ); ?></th>
167 - <td>
168 - <?php echo wp_kses_post( $order_received->get_formatted_order_total() ); ?>
169 - </td>
170 - </tr>
171 - <?php
172 - $method_title = $order_received->get_payment_method_title();
173 - if ( $method_title ) :
174 - ?>
175 - <tr class="method">
176 - <th><?php esc_html_e( 'Payment Method', 'learnpress' ); ?></th>
177 - <td>
178 - <?php echo esc_html( $method_title ); ?>
179 - </td>
180 - </tr>
181 - <?php endif; ?>
182 - <?php do_action( 'learn-press/order/received/items-table', $order_received ); ?>
183 - </table>
184 -
185 - <?php do_action( 'learn-press/order/received', $order_received ); ?>
186 -</div>
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>