PluginProbe
Tutor LMS – eLearning and online course solution / 4.0.6
Tutor LMS – eLearning and online course solution v4.0.6
4.0.7 4.0.6 4.0.5 4.0.4 4.0.3 4.0.2 4.0.1 4.0.0 3.9.15 3.9.14 3.9.13 3.9.12 3.9.11 trunk 1.0.0 1.0.0-alpha 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 1.0.8 1.0.9 All 191 releases
tutor / templates / ecommerce / cart.php
cart.php
170 lines 6.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Cart Template
4 * For tutor monetization.
5 *
6 * @package Tutor\Views
7 * @author Themeum <support@themeum.com>
8 * @link https://themeum.com
9 * @since 3.0.0
10 */
11
12 if ( ! defined( 'ABSPATH' ) ) {
13 exit;
14 }
15
16 use Tutor\Ecommerce\CartController;
17 use Tutor\Ecommerce\CheckoutController;
18 use Tutor\Ecommerce\Tax;
19 use Tutor\Models\CourseModel;
20
21 $cart_controller = new CartController();
22 $get_cart = $cart_controller->get_cart_items();
23 $courses = $get_cart['courses'];
24 $total_count = $courses['total_count'];
25 $course_list = $courses['results'];
26
27 $subtotal = 0;
28 $tax_exempt_price = 0;
29
30 $checkout_page_url = CheckoutController::get_page_url();
31
32 ?>
33 <div class="tutor-cart-page">
34 <div class="tutor-cart-page-wrapper">
35 <div class="tutor-container">
36 <?php if ( is_array( $course_list ) && count( $course_list ) ) : ?>
37 <div class="tutor-row tutor-g-4">
38 <div class="tutor-col-lg-8">
39 <h3 class="tutor-fs-3 tutor-fw-bold tutor-color-black tutor-mb-16">
40 <?php
41 // translators: %d: Number of courses in the cart.
42 echo esc_html( sprintf( _n( '%d Course in Cart', '%d Courses in Cart', $total_count, 'tutor' ), $total_count ) );
43 ?>
44 </h3>
45
46 <div class="tutor-cart-course-list">
47 <?php
48 foreach ( $course_list as $key => $course ) :
49 $course_duration = get_tutor_course_duration_context( $course->ID, true );
50 $course_price = tutor_utils()->get_raw_course_price( $course->ID );
51 $regular_price = $course_price->regular_price;
52 $sale_price = $course_price->sale_price;
53 $display_price = $sale_price ? $sale_price : $regular_price;
54 $tutor_course_img = get_tutor_course_thumbnail_src( '', $course->ID );
55
56 $subtotal += $display_price;
57
58 $tax_collection = CourseModel::is_tax_enabled_for_single_purchase( $course->ID );
59 if ( ! $tax_collection ) {
60 $tax_exempt_price += $display_price;
61 }
62 ?>
63 <div class="tutor-cart-course-item">
64 <div class="tutor-cart-course-thumb">
65 <a href="<?php echo esc_url( get_the_permalink( $course ) ); ?>">
66 <img src="<?php echo esc_url( $tutor_course_img ); ?>" alt="Course thumb">
67 </a>
68 </div>
69 <div class="tutor-cart-course-title">
70 <div class="tutor-d-flex tutor-align-center tutor-gap-4px">
71 <?php do_action( 'tutor_cart_item_badge', $course ); ?>
72 </div>
73 <h5 class="tutor-fs-6 tutor-fw-medium tutor-color-black">
74 <a href="<?php echo esc_url( get_the_permalink( $course ) ); ?>">
75 <?php echo esc_html( $course->post_title ); ?>
76 </a>
77 </h5>
78 <ul class="tutor-cart-course-info">
79 <?php if ( $course_duration ) : ?>
80 <li><?php echo esc_html( tutor_utils()->clean_html_content( $course_duration ) ); ?> <span></span></li>
81 <?php endif; ?>
82 <li><?php echo esc_html( get_tutor_course_level( $course->ID ) ); ?></li>
83 </ul>
84 </div>
85 <div class="tutor-cart-course-price-wrapper">
86 <div class="tutor-cart-course-price">
87 <div class="tutor-fw-bold">
88 <?php tutor_print_formatted_price( $display_price ); ?>
89 </div>
90 <?php if ( $regular_price && $sale_price && $sale_price !== $regular_price ) : ?>
91 <div class="tutor-cart-discount-price">
92 <?php tutor_print_formatted_price( $regular_price ); ?>
93 </div>
94 <?php endif; ?>
95 </div>
96 <button class="tutor-btn tutor-btn-link tutor-cart-remove-button" data-course-id="<?php echo esc_attr( $course->ID ); ?>">
97 <?php esc_html_e( 'Remove', 'tutor' ); ?>
98 </button>
99 </div>
100 </div>
101 <?php endforeach; ?>
102 </div>
103 </div>
104 <?php
105 $should_calculate_tax = Tax::should_calculate_tax();
106 $is_tax_included_in_price = Tax::is_tax_included_in_price();
107 $tax_rate = Tax::get_user_tax_rate();
108 $show_tax_incl_text = $should_calculate_tax && $tax_rate > 0 && $is_tax_included_in_price;
109 $tax_amount = 0;
110
111 if ( $should_calculate_tax ) {
112 $tax_amount = Tax::calculate_tax( $subtotal, $tax_rate );
113 $tax_exempt_amount = Tax::calculate_tax( $tax_exempt_price, $tax_rate );
114 $tax_amount = $tax_amount - $tax_exempt_amount;
115 }
116
117 $grand_total = $subtotal;
118 if ( ! $is_tax_included_in_price ) {
119 $grand_total += $tax_amount;
120 }
121 ?>
122 <div class="tutor-col-lg-4">
123 <h3 class="tutor-fs-3 tutor-fw-bold tutor-color-black tutor-mb-16"><div><?php esc_html_e( 'Summary:', 'tutor' ); ?></div></h3>
124 <div class="tutor-cart-summery">
125 <div class="tutor-cart-summery-top">
126 <div class="tutor-cart-summery-item tutor-fw-medium">
127 <div><?php esc_html_e( 'Subtotal:', 'tutor' ); ?></div>
128 <div><?php tutor_print_formatted_price( $subtotal ); ?></div>
129 </div>
130 <?php if ( $should_calculate_tax && $tax_rate > 0 && ! $is_tax_included_in_price ) : ?>
131 <div class="tutor-cart-summery-item">
132 <div><?php esc_html_e( 'Tax:', 'tutor' ); ?></div>
133 <div><?php tutor_print_formatted_price( $tax_amount ); ?></div>
134 </div>
135 <?php endif; ?>
136 </div>
137 <div class="tutor-cart-summery-bottom">
138 <div class="tutor-cart-summery-item tutor-fw-medium <?php echo esc_attr( $show_tax_incl_text ? '' : 'tutor-mb-40' ); ?>">
139 <div><?php esc_html_e( 'Grand total', 'tutor' ); ?></div>
140 <div><?php tutor_print_formatted_price( $grand_total ); ?></div>
141 </div>
142 <?php
143 if ( $should_calculate_tax && $tax_rate > 0 && $is_tax_included_in_price ) :
144 ?>
145 <div class="tutor-text-right tutor-fs-7 tutor-color-muted tutor-mb-40">
146 <?php
147 /* translators: %s: tax amount */
148 echo esc_html( sprintf( __( '(Incl. Tax %s)', 'tutor' ), tutor_get_formatted_price( $tax_amount ) ) );
149 ?>
150 </div>
151 <?php endif ?>
152
153 <a data-cy="tutor-native-checkout-button" class="tutor-btn tutor-btn-primary tutor-btn-lg tutor-w-100 tutor-justify-center <?php echo esc_attr( $checkout_page_url ? '' : 'tutor-checkout-page-not-configured' ); ?>" href="<?php echo esc_url( $checkout_page_url ? $checkout_page_url : '#' ); ?>">
154 <?php esc_html_e( 'Proceed to checkout', 'tutor' ); ?>
155 </a>
156 </div>
157 </div>
158 </div>
159 </div>
160 <?php else : ?>
161 <div class="tutor-cart-empty-state">
162 <img src="<?php echo esc_url( tutor()->url ); ?>assets/images/empty-cart.svg" alt="<?php esc_html_e( 'Empty shopping cart', 'tutor' ); ?>" />
163 <p><?php esc_html_e( 'No courses in the cart', 'tutor' ); ?></p>
164 <a href="<?php echo esc_url( tutor_utils()->course_archive_page_url() ); ?>" class="tutor-btn tutor-btn-lg tutor-btn-primary"><?php esc_html_e( 'Continue Browsing', 'tutor' ); ?></a>
165 </div>
166 <?php endif; ?>
167 </div>
168 </div>
169 </div>
170