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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 / ecommerce / checkout-details.php
tutor / templates / ecommerce Last commit date
billing-form-fields.php 1 year ago billing.php 1 year ago cart.php 10 months ago checkout-details.php 10 months ago checkout.php 11 months ago order-placement-failed.php 1 year ago order-placement-success.php 1 year ago
checkout-details.php
224 lines
1 <?php
2 /**
3 * Checkout info template
4 *
5 * @package Tutor\Views
6 * @author Themeum <support@themeum.com>
7 * @link https://themeum.com
8 * @since 3.0.0
9 */
10
11 use TUTOR\Input;
12 use Tutor\Ecommerce\Tax;
13 use Tutor\Models\OrderModel;
14 use Tutor\Ecommerce\Settings;
15 use Tutor\Models\CouponModel;
16 use Tutor\Ecommerce\CartController;
17 use Tutor\Ecommerce\CheckoutController;
18
19 /**
20 * User ID is required.
21 * Renders this view only (excluding checkout.php) when the country or state changes via AJAX.
22 */
23 $user_id = apply_filters( 'tutor_checkout_user_id', get_current_user_id() );
24
25 $coupon_model = new CouponModel();
26 $cart_controller = new CartController( false );
27 $checkout_controller = new CheckoutController( false );
28 $get_cart = $cart_controller->get_cart_items();
29 $courses = $get_cart['courses'];
30 $total_count = $courses['total_count'];
31 $course_id = (int) Input::sanitize_request_data( 'course_id', 0 );
32 $course_list = Settings::is_buy_now_enabled() && $course_id ? array( get_post( $course_id ) ) : $courses['results'];
33
34 $plan_id = (int) Input::sanitize_request_data( 'plan' );
35 $plan_info = apply_filters( 'tutor_get_plan_info', null, $plan_id );
36 $has_plan_info = $plan_id && $plan_info;
37
38 // Contains Course/Bundle/Plan ids.
39 $object_ids = array();
40 $item_ids = $has_plan_info ? array( $plan_info->id ) : array_column( $course_list, 'ID' );
41 $order_type = $has_plan_info ? OrderModel::TYPE_SUBSCRIPTION : OrderModel::TYPE_SINGLE_ORDER;
42
43 $coupon_code = apply_filters( 'tutor_checkout_coupon_code', Input::sanitize_request_data( 'coupon_code', '' ), $order_type, $item_ids );
44 $has_manual_coupon_code = ! empty( $coupon_code );
45
46 $should_calculate_tax = Tax::should_calculate_tax();
47 $is_tax_included_in_price = Tax::is_tax_included_in_price();
48 $tax_rate = Tax::get_user_tax_rate( $user_id );
49
50 $checkout_data = $checkout_controller->prepare_checkout_items( $item_ids, $order_type, $coupon_code );
51 $show_coupon_box = Settings::is_coupon_usage_enabled() && ! $checkout_data->is_coupon_applied;
52 ?>
53
54 <div class="tutor-checkout-details">
55
56 <?php do_action( 'tutor_before_checkout_order_details', $course_list ); ?>
57
58 <div class="tutor-checkout-details-inner">
59 <h5 class="tutor-fs-5 tutor-fw-medium tutor-color-black tutor-border-bottom tutor-pb-8">
60 <?php esc_html_e( 'Order Details', 'tutor' ); ?>
61 </h5>
62 <div class="tutor-checkout-detail-item">
63 <div class="tutor-checkout-courses">
64 <?php
65 // Subscription plan checkout item.
66 if ( $plan_info ) {
67 $plan_item_template = apply_filters( 'tutor_checkout_plan_item_template', null, $plan_info );
68 if ( file_exists( $plan_item_template ) ) {
69 require $plan_item_template;
70 }
71 } else {
72 /**
73 * Course and bundle checkout items.
74 */
75 if ( is_array( $course_list ) && count( $course_list ) ) :
76 ?>
77 <?php
78 foreach ( $checkout_data->items as $item ) :
79 $course = get_post( $item->item_id );
80 $course_thumbnail = get_tutor_course_thumbnail_src( 'post-thumbnail', $course->ID );
81 array_push( $object_ids, $item->item_id );
82 ?>
83 <div class="tutor-checkout-course-item" data-course-id="<?php echo esc_attr( $item->item_id ); ?>">
84 <div class="tutor-d-flex tutor-align-center tutor-gap-4px">
85 <?php do_action( 'tutor_cart_item_badge', $course ); ?>
86 </div>
87 <div class="tutor-checkout-course-content">
88 <div class="tutor-d-flex tutor-flex-column tutor-gap-1">
89 <div class="tutor-checkout-course-thumb-title">
90 <img src="<?php echo esc_url( $course_thumbnail ); ?>" alt="<?php echo esc_attr( $course->post_title ); ?>" />
91 <h6 class="tutor-checkout-course-title">
92 <a href="<?php echo esc_url( get_the_permalink( $course ) ); ?>">
93 <?php echo esc_html( $course->post_title ); ?>
94 </a>
95 </h6>
96 </div>
97 <div class="tutor-checkout-coupon-badge <?php echo esc_attr( $item->is_coupon_applied ? '' : 'tutor-d-none' ); ?>">
98 <i class="tutor-icon-tag" area-hidden="true"></i>
99 <span><?php echo esc_html( $item->is_coupon_applied ? $checkout_data->coupon_title : '' ); ?></span>
100 </div>
101 </div>
102 <div class="tutor-text-right">
103 <div class="tutor-fw-bold">
104 <?php tutor_print_formatted_price( $item->display_price ); ?>
105 </div>
106 <?php if ( $item->sale_price || $item->discount_price ) : ?>
107 <div class="tutor-checkout-discount-price">
108 <?php tutor_print_formatted_price( $item->regular_price ); ?>
109 </div>
110 <?php endif; ?>
111 <?php if ( $checkout_data->total_items > 1 && $item->tax_amount > 0 && $item->tax_collection ) : ?>
112 <div class="tutor-fs-8 tutor-color-muted tutor-checkout-incl-tax-label">
113 <?php echo esc_html( $item->tax_amount_readable ); ?>
114 </div>
115 <?php endif; ?>
116 </div>
117 </div>
118 </div>
119 <?php endforeach; ?>
120 <?php else : ?>
121 <?php tutor_utils()->tutor_empty_state( tutor_utils()->not_found_text() ); ?>
122 <?php endif; ?>
123 <?php } ?>
124 </div>
125 </div>
126
127 <div class="tutor-checkout-detail-item tutor-checkout-summary">
128 <div class="tutor-checkout-summary-item">
129 <div class="tutor-fw-medium"><?php esc_html_e( 'Subtotal', 'tutor' ); ?></div>
130 <div class="tutor-fw-bold">
131 <?php tutor_print_formatted_price( $checkout_data->subtotal_price ); ?>
132 </div>
133 </div>
134
135 <?php if ( $checkout_data->sale_discount > 0 ) : ?>
136 <div class="tutor-checkout-summary-item">
137 <div>
138 <?php
139 $sale_discount_label = apply_filters( 'tutor_checkout_sale_discount_label', __( 'Sale discount', 'tutor' ) );
140 echo esc_html( $sale_discount_label );
141 ?>
142 </div>
143 <div class="tutor-fw-bold">
144 - <?php tutor_print_formatted_price( $checkout_data->sale_discount ); ?>
145 </div>
146 </div>
147 <?php endif ?>
148
149 <?php if ( $show_coupon_box ) : ?>
150 <div class="tutor-checkout-summary-item tutor-have-a-coupon">
151 <div><?php esc_html_e( 'Have a coupon?', 'tutor' ); ?></div>
152 <button type="button" id="tutor-toggle-coupon-button" class="tutor-btn tutor-btn-link">
153 <?php esc_html_e( 'Click here', 'tutor' ); ?>
154 </button>
155 </div>
156 <div class="tutor-apply-coupon-form tutor-d-none">
157 <input type="text" name="coupon_code"
158 <?php if ( 'manual' === $checkout_data->coupon_type && $checkout_data->is_coupon_applied ) : ?>
159 value="<?php echo esc_attr( $coupon_code ); ?>"
160 <?php endif; ?>
161 placeholder="<?php esc_html_e( 'Add coupon code', 'tutor' ); ?>">
162 <button type="button" id="tutor-apply-coupon-button" class="tutor-btn tutor-btn-secondary" data-object-ids="<?php echo esc_attr( implode( ',', $object_ids ) ); ?>"><?php esc_html_e( 'Apply', 'tutor' ); ?></button>
163 </div>
164 <?php endif; ?>
165
166 <div class="tutor-checkout-summary-item tutor-checkout-coupon-wrapper <?php echo esc_attr( $checkout_data->is_coupon_applied ? '' : 'tutor-d-none' ); ?>">
167 <div class="tutor-checkout-coupon-badge tutor-has-delete-button">
168 <i class="tutor-icon-tag" area-hidden="true"></i>
169 <span><?php echo esc_html( $checkout_data->coupon_title ); ?></span>
170
171 <?php if ( $checkout_data->is_coupon_applied ) : ?>
172 <button type="button" id="tutor-checkout-remove-coupon" class="tutor-btn">
173 <i class="tutor-icon-times" area-hidden="true"></i>
174 </button>
175 <?php endif; ?>
176 </div>
177 <div class="tutor-fw-bold tutor-discount-amount">-<?php tutor_print_formatted_price( $checkout_data->coupon_discount ); ?></div>
178 </div>
179
180 <?php if ( $checkout_data->tax_amount > 0 && ! $is_tax_included_in_price ) : ?>
181 <div class="tutor-checkout-summary-item tutor-checkout-tax-amount">
182 <div><?php esc_html_e( 'Tax', 'tutor' ); ?></div>
183 <div class="tutor-fw-bold"><?php tutor_print_formatted_price( $checkout_data->tax_amount ); ?></div>
184 </div>
185 <?php endif; ?>
186 </div>
187
188 <div class="tutor-pt-12 tutor-pb-20">
189 <div class="tutor-checkout-summary-item">
190 <div class="tutor-fw-medium"><?php esc_html_e( 'Grand Total', 'tutor' ); ?></div>
191 <div class="tutor-fs-5 tutor-fw-bold tutor-checkout-grand-total">
192 <?php tutor_print_formatted_price( $checkout_data->total_price ); ?>
193 </div>
194 </div>
195 <div class="tutor-checkout-summary-item tutor-checkout-incl-tax-label">
196 <div></div>
197 <?php if ( $checkout_data->tax_amount > 0 && $is_tax_included_in_price ) : ?>
198 <div class="tutor-fs-7 tutor-color-muted">
199 <?php
200 /* translators: %s: tax amount */
201 echo esc_html( sprintf( __( '(Incl. Tax %s)', 'tutor' ), tutor_get_formatted_price( $checkout_data->tax_amount ) ) );
202 ?>
203 </div>
204 <?php endif ?>
205 </div>
206
207 <input type="hidden" name="coupon_code" value="<?php echo esc_attr( $coupon_code ); ?>">
208 <input type="hidden" name="object_ids" value="<?php echo esc_attr( implode( ',', $object_ids ) ); ?>">
209 <input type="hidden" name="order_type" value="<?php echo esc_attr( $order_type ); ?>">
210 </div>
211
212 <?php
213 $is_zero_price = empty( $checkout_data->total_price ) && OrderModel::TYPE_SINGLE_ORDER === $checkout_data->order_type;
214 $pay_now_btn_text = $is_zero_price ? __( 'Enroll Now', 'tutor' ) : __( 'Pay Now', 'tutor' );
215 $pay_now_btn_text = apply_filters( 'tutor_checkout_pay_now_btn_text', $pay_now_btn_text, $checkout_data );
216 $show_payment_methods = apply_filters( 'tutor_checkout_show_payment_methods', ! $is_zero_price, $checkout_data );
217
218 $checkout_data->pay_now_btn_text = $pay_now_btn_text;
219 $checkout_data->payment_method_required = $show_payment_methods;
220 ?>
221 <input type="hidden" id="checkout_data" value="<?php echo esc_attr( wp_json_encode( $checkout_data ) ); ?>">
222 </div>
223 </div>
224