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 +161 -99 4.2.04.4.8 View file →
@@ -5,122 +5,184 @@
5 5 * This template can be overridden by copying it to yourtheme/learnpress/checkout/order-received.php.
6 6 *
7 7 * @author ThimPress
8 8 * @package Learnpress/Templates
9 - * @version 4.0.1
9 + * @version 4.0.4
10 10 */
11 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 +
12 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 );
13 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 + );
14 39
15 -<?php
16 -/**
17 - * @var LP_Order $order_received
18 - */
19 -if ( ! isset( $order_received ) ) {
40 + return;
41 + }
42 +
20 43 echo wp_sprintf(
21 - '<p>%s</p>',
44 + '<p>%s</p><p>%s</p>',
22 45 esc_html(
23 46 apply_filters(
24 - 'learn-press/order/received-invalid-order-message',
25 - __( 'Invalid order.', 'learnpress' )
47 + 'learn-press/order/received-order-message',
48 + __( 'Thank you. Your order has been received.', 'learnpress' )
26 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 + )
27 63 )
28 64 );
65 + do_action( 'learn-press/order/after-received-order-message', $order_received->get_id() );
29 66
30 - return;
31 -}
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 );
32 100
33 -echo wp_sprintf(
34 - '<p>%s</p>',
35 - esc_html(
36 - apply_filters(
37 - 'learn-press/order/received-order-message',
38 - __( 'Thank you. Your order has been received.', 'learnpress' )
39 - )
40 - )
41 -);
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();
42 117
43 -?>
44 -<table class="order_details">
45 - <?php if ( isset( $_GET['key'] ) && ! is_user_logged_in() ) : ?>
46 - <tr class="order-key">
47 - <th><?php esc_html_e( 'Order Key', 'learnpress' ); ?></th>
48 - <td>
49 - <?php echo esc_html( $_GET['key'] ); ?>
50 - </td>
51 - </tr>
52 - <?php endif; ?>
53 - <tr class="order">
54 - <th><?php esc_html_e( 'Order Number', 'learnpress' ); ?></th>
55 - <td>
56 - <?php echo esc_html( $order_received->get_order_number() ); ?>
57 - </td>
58 - </tr>
59 - <tr class="item">
60 - <th><?php esc_html_e( 'Item', 'learnpress' ); ?></th>
61 - <td>
62 - <?php
63 - $links = array();
64 - $items = $order_received->get_items();
65 - $count = count( $items );
118 + // Load js button course.
119 + wp_enqueue_script( 'lp-single-course' );
66 120
67 - foreach ( $items as $item ) {
68 - if ( empty( $item['course_id'] ) || get_post_type( $item['course_id'] ) !== LP_COURSE_CPT ) {
69 - $links[] = apply_filters(
70 - 'learn-press/order-item-not-course-id',
71 - __( 'The course does not exist', 'learnpress' ),
72 - $item
73 - );
74 - } else {
75 - $link = '<a href="' . get_the_permalink( $item['course_id'] ) . '">' . get_the_title( $item['course_id'] ) . ' (#' . $item['course_id'] . ')' . '</a>';
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 +
76 143 if ( $count > 1 ) {
77 - $link = sprintf( '<li>%s</li>', $link );
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' );
78 149 }
79 - $links[] = apply_filters( 'learn-press/order-received-item-link', $link, $item );
80 - }
81 - }
82 -
83 - if ( $count > 1 ) {
84 - echo sprintf( '<ol>%s</ol>', join( '', $links ) );
85 - } elseif ( 1 == $count ) {
86 - echo wp_kses_post( implode( '', $links ) );
87 - } else {
88 - echo esc_html__( '(No item)', 'learnpress' );
89 - }
90 - ?>
91 - </td>
92 - </tr>
93 - <tr class="date">
94 - <th><?php esc_html_e( 'Date', 'learnpress' ); ?></th>
95 - <td>
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>
96 172 <?php
97 - echo wp_kses_post(
98 - date_i18n(
99 - get_option( 'date_format' ),
100 - strtotime( $order_received->get_order_date() )
101 - )
102 - );
103 - ?>
104 - </td>
105 - </tr>
106 - <tr class="total">
107 - <th><?php esc_html_e( 'Total', 'learnpress' ); ?></th>
108 - <td>
109 - <?php echo wp_kses_post( $order_received->get_formatted_order_total() ); ?>
110 - </td>
111 - </tr>
112 - <?php
113 - $method_title = $order_received->get_payment_method_title();
114 - if ( $method_title ) :
115 - ?>
116 - <tr class="method">
117 - <th><?php esc_html_e( 'Payment Method', 'learnpress' ); ?></th>
118 - <td>
119 - <?php echo esc_html( $method_title ); ?>
120 - </td>
121 - </tr>
122 - <?php endif; ?>
123 -</table>
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>
124 186
125 -<?php //do_action( 'learn-press/order/received/' . $order_received->get_data( 'payment_method' ), $order_received->get_id() ); ?>
126 -<?php do_action( 'learn-press/order/received', $order_received ); ?>
187 + <?php do_action( 'learn-press/order/received', $order_received ); ?>
188 +</div>