billing-form-fields.php
1 year ago
billing.php
1 year ago
cart.php
1 year ago
checkout-details.php
1 year ago
checkout.php
1 year ago
order-placement-failed.php
1 year ago
order-placement-success.php
1 year ago
cart.php
162 lines
| 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 | |
| 20 | $cart_controller = new CartController(); |
| 21 | $get_cart = $cart_controller->get_cart_items(); |
| 22 | $courses = $get_cart['courses']; |
| 23 | $total_count = $courses['total_count']; |
| 24 | $course_list = $courses['results']; |
| 25 | $subtotal = 0; |
| 26 | |
| 27 | $checkout_page_url = CheckoutController::get_page_url(); |
| 28 | |
| 29 | ?> |
| 30 | <div class="tutor-cart-page"> |
| 31 | <div class="tutor-cart-page-wrapper"> |
| 32 | <div class="tutor-container"> |
| 33 | <?php if ( is_array( $course_list ) && count( $course_list ) ) : ?> |
| 34 | <div class="tutor-row tutor-g-4"> |
| 35 | <div class="tutor-col-lg-8"> |
| 36 | <h3 class="tutor-fs-3 tutor-fw-bold tutor-color-black tutor-mb-16"> |
| 37 | <?php |
| 38 | // translators: %d: Number of courses in the cart. |
| 39 | echo esc_html( sprintf( _n( '%d Course in Cart', '%d Courses in Cart', $total_count, 'tutor' ), $total_count ) ); |
| 40 | ?> |
| 41 | </h3> |
| 42 | |
| 43 | <div class="tutor-cart-course-list"> |
| 44 | <?php |
| 45 | foreach ( $course_list as $key => $course ) : |
| 46 | $course_duration = get_tutor_course_duration_context( $course->ID, true ); |
| 47 | $course_price = tutor_utils()->get_raw_course_price( $course->ID ); |
| 48 | $regular_price = $course_price->regular_price; |
| 49 | $sale_price = $course_price->sale_price; |
| 50 | $tutor_course_img = get_tutor_course_thumbnail_src( '', $course->ID ); |
| 51 | |
| 52 | $subtotal += $sale_price ? $sale_price : $regular_price; |
| 53 | ?> |
| 54 | <div class="tutor-cart-course-item"> |
| 55 | <div class="tutor-cart-course-thumb"> |
| 56 | <a href="<?php echo esc_url( get_the_permalink( $course ) ); ?>"> |
| 57 | <img src="<?php echo esc_url( $tutor_course_img ); ?>" alt="Course thumb"> |
| 58 | </a> |
| 59 | </div> |
| 60 | <div class="tutor-cart-course-title"> |
| 61 | <?php if ( tutor()->has_pro && 'course-bundle' === $course->post_type ) : ?> |
| 62 | <div class="tutor-cart-course-bundle-badge"> |
| 63 | <?php |
| 64 | $bundle_model = new \TutorPro\CourseBundle\Models\BundleModel(); |
| 65 | $bundle_course_ids = $bundle_model::get_bundle_course_ids( $course->ID ); |
| 66 | // translators: %d: Number of courses in the cart. |
| 67 | echo esc_html( sprintf( __( '%d Course bundle', 'tutor' ), count( $bundle_course_ids ) ) ); |
| 68 | ?> |
| 69 | </div> |
| 70 | <?php endif; ?> |
| 71 | <h5 class="tutor-fs-6 tutor-fw-medium tutor-color-black"> |
| 72 | <a href="<?php echo esc_url( get_the_permalink( $course ) ); ?>"> |
| 73 | <?php echo esc_html( $course->post_title ); ?> |
| 74 | </a> |
| 75 | </h5> |
| 76 | <ul class="tutor-cart-course-info"> |
| 77 | <?php if ( $course_duration ) : ?> |
| 78 | <li><?php echo esc_html( tutor_utils()->clean_html_content( $course_duration ) ); ?> <span></span></li> |
| 79 | <?php endif; ?> |
| 80 | <li><?php echo esc_html( get_tutor_course_level( $course->ID ) ); ?></li> |
| 81 | </ul> |
| 82 | </div> |
| 83 | <div class="tutor-cart-course-price-wrapper"> |
| 84 | <div class="tutor-cart-course-price"> |
| 85 | <div class="tutor-fw-bold"> |
| 86 | <?php echo tutor_get_formatted_price( $sale_price ? $sale_price : $regular_price ); //phpcs:ignore?> |
| 87 | </div> |
| 88 | <?php if ( $regular_price && $sale_price && $sale_price !== $regular_price ) : ?> |
| 89 | <div class="tutor-cart-discount-price"> |
| 90 | <?php echo tutor_get_formatted_price( $regular_price ); //phpcs:ignore?> |
| 91 | </div> |
| 92 | <?php endif; ?> |
| 93 | </div> |
| 94 | <button class="tutor-btn tutor-btn-link tutor-cart-remove-button" data-course-id="<?php echo esc_attr( $course->ID ); ?>"> |
| 95 | <?php esc_html_e( 'Remove', 'tutor' ); ?> |
| 96 | </button> |
| 97 | </div> |
| 98 | </div> |
| 99 | <?php endforeach; ?> |
| 100 | </div> |
| 101 | </div> |
| 102 | <?php |
| 103 | $is_tax_configured = Tax::is_tax_configured(); |
| 104 | $is_tax_included_in_price = Tax::is_tax_included_in_price(); |
| 105 | $tax_rate = Tax::get_user_tax_rate(); |
| 106 | $tax_amount = Tax::calculate_tax( $subtotal, $tax_rate ); |
| 107 | $grand_total = $subtotal; |
| 108 | $show_tax_incl_text = $is_tax_configured && $tax_rate > 0 && $is_tax_included_in_price; |
| 109 | |
| 110 | if ( ! $is_tax_included_in_price ) { |
| 111 | $grand_total += $tax_amount; |
| 112 | } |
| 113 | ?> |
| 114 | <div class="tutor-col-lg-4"> |
| 115 | <h3 class="tutor-fs-3 tutor-fw-bold tutor-color-black tutor-mb-16"><div><?php esc_html_e( 'Summary:', 'tutor' ); ?></div></h3> |
| 116 | <div class="tutor-cart-summery"> |
| 117 | <div class="tutor-cart-summery-top"> |
| 118 | <div class="tutor-cart-summery-item tutor-fw-medium"> |
| 119 | <div><?php esc_html_e( 'Subtotal:', 'tutor' ); ?></div> |
| 120 | <div><?php tutor_print_formatted_price( $subtotal ); ?></div> |
| 121 | </div> |
| 122 | <?php if ( $is_tax_configured && $tax_rate > 0 && ! $is_tax_included_in_price ) : ?> |
| 123 | <div class="tutor-cart-summery-item"> |
| 124 | <div><?php esc_html_e( 'Tax:', 'tutor' ); ?></div> |
| 125 | <div><?php tutor_print_formatted_price( $tax_amount ); ?></div> |
| 126 | </div> |
| 127 | <?php endif; ?> |
| 128 | </div> |
| 129 | <div class="tutor-cart-summery-bottom"> |
| 130 | <div class="tutor-cart-summery-item tutor-fw-medium <?php echo esc_attr( $show_tax_incl_text ? '' : 'tutor-mb-40' ); ?>"> |
| 131 | <div><?php esc_html_e( 'Grand total', 'tutor' ); ?></div> |
| 132 | <div><?php tutor_print_formatted_price( $grand_total ); ?></div> |
| 133 | </div> |
| 134 | <?php |
| 135 | if ( $is_tax_configured && $tax_rate > 0 && $is_tax_included_in_price ) : |
| 136 | ?> |
| 137 | <div class="tutor-text-right tutor-fs-7 tutor-color-muted tutor-mb-40"> |
| 138 | <?php |
| 139 | /* translators: %s: tax amount */ |
| 140 | echo esc_html( sprintf( __( '(Incl. Tax %s)', 'tutor' ), tutor_get_formatted_price( $tax_amount ) ) ); |
| 141 | ?> |
| 142 | </div> |
| 143 | <?php endif ?> |
| 144 | |
| 145 | <a 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 : '#' ); ?>"> |
| 146 | <?php esc_html_e( 'Proceed to checkout', 'tutor' ); ?> |
| 147 | </a> |
| 148 | </div> |
| 149 | </div> |
| 150 | </div> |
| 151 | </div> |
| 152 | <?php else : ?> |
| 153 | <div class="tutor-cart-empty-state"> |
| 154 | <img src="<?php echo esc_url( tutor()->url ); ?>assets/images/empty-cart.svg" alt="<?php esc_html_e( 'Empty shopping cart', 'tutor' ); ?>" /> |
| 155 | <p><?php esc_html_e( 'No courses in the cart', 'tutor' ); ?></p> |
| 156 | <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> |
| 157 | </div> |
| 158 | <?php endif; ?> |
| 159 | </div> |
| 160 | </div> |
| 161 | </div> |
| 162 |