enrolled
1 month ago
add-to-cart-edd.php
1 month ago
add-to-cart-tutor.php
1 year ago
add-to-cart-woocommerce.php
1 year ago
continue-lesson.php
3 years ago
course-benefits.php
4 months ago
course-content.php
4 months ago
course-entry-box.php
1 month ago
course-requirements.php
4 months ago
course-target-audience.php
4 months ago
course-topics.php
1 month ago
instructors.php
3 years ago
lead-info.php
11 months ago
material-includes.php
4 months ago
q_and_a_turned_off.php
3 years ago
reviews-loop.php
1 month ago
reviews.php
1 month ago
social_share.php
3 years ago
tags.php
3 years ago
wc-price-html.php
3 years ago
add-to-cart-woocommerce.php
85 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Tutor add to cart for WC product that will be visible on the course details page |
| 4 | * |
| 5 | * @package Tutor\Templates |
| 6 | * @subpackage Single\Course |
| 7 | * @author Themeum <support@themeum.com> |
| 8 | * @link https://themeum.com |
| 9 | * @since 1.4.3 |
| 10 | */ |
| 11 | |
| 12 | $product_id = tutor_utils()->get_course_product_id(); |
| 13 | $product = wc_get_product( $product_id ); |
| 14 | |
| 15 | $is_logged_in = is_user_logged_in(); |
| 16 | $enable_guest_course_cart = tutor_utils()->get_option( 'enable_guest_course_cart' ); |
| 17 | $required_loggedin_class = ''; |
| 18 | if ( ! $is_logged_in && ! $enable_guest_course_cart ) { |
| 19 | $required_loggedin_class = apply_filters( 'tutor_enroll_required_login_class', 'tutor-open-login-modal' ); |
| 20 | } |
| 21 | |
| 22 | if ( $product ) { |
| 23 | if ( tutor_utils()->is_course_added_to_cart( $product_id, true ) ) { |
| 24 | ?> |
| 25 | <a href="<?php echo esc_url( wc_get_cart_url() ); ?>" class="tutor-btn tutor-btn-outline-primary tutor-btn-lg tutor-btn-block tutor-woocommerce-view-cart"> |
| 26 | <?php esc_html_e( 'View Cart', 'tutor' ); ?> |
| 27 | </a> |
| 28 | <?php |
| 29 | } else { |
| 30 | $regular_price = wc_get_price_to_display( $product, array( 'price' => $product->get_regular_price() ) ); |
| 31 | $sale_price = wc_get_price_to_display( $product, array( 'price' => $product->get_sale_price() ) ); |
| 32 | $tax_display = get_option( 'woocommerce_tax_display_shop' ); |
| 33 | ?> |
| 34 | <div> |
| 35 | <div class="tutor-course-sidebar-card-pricing tutor-d-flex tutor-align-end tutor-justify-between"> |
| 36 | <?php ob_start(); ?> |
| 37 | <div> |
| 38 | <span class="tutor-fs-4 tutor-fw-bold tutor-color-black"> |
| 39 | <?php echo wc_price( $sale_price ? $sale_price : $regular_price ); //phpcs:ignore?> |
| 40 | </span> |
| 41 | <?php if ( $regular_price && $sale_price && $sale_price !== $regular_price ) : ?> |
| 42 | <del class="tutor-fs-7 tutor-color-muted tutor-ml-8"> |
| 43 | <?php echo wc_price( $regular_price ); //phpcs:ignore?> |
| 44 | </del> |
| 45 | <?php endif; ?> |
| 46 | </div> |
| 47 | </div> |
| 48 | <div class="tutor-color-muted"> |
| 49 | <?php |
| 50 | if ( 'incl' === $tax_display ) { |
| 51 | echo wp_kses( |
| 52 | $product->get_price_suffix(), |
| 53 | array( 'small' => array( 'class' => true ) ) |
| 54 | ); |
| 55 | } |
| 56 | ?> |
| 57 | </div> |
| 58 | <?php |
| 59 | /** |
| 60 | * Added to show info about price. |
| 61 | * |
| 62 | * @since 2.2.0 |
| 63 | */ |
| 64 | do_action( 'tutor_after_course_details_wc_cart_price', $product, get_the_ID() ); |
| 65 | ?> |
| 66 | <?php echo apply_filters( 'tutor_course_details_wc_add_to_cart_price', ob_get_clean(), $product ); //phpcs:ignore ?> |
| 67 | </div> |
| 68 | <?php ob_start(); ?> |
| 69 | <form action="<?php echo esc_url( apply_filters( 'tutor_course_add_to_cart_form_action', get_permalink( get_the_ID() ) ) ); ?>" method="post" enctype="multipart/form-data"> |
| 70 | <button type="submit" name="add-to-cart" value="<?php echo esc_attr( $product->get_id() ); ?>" class="tutor-btn tutor-btn-primary tutor-btn-lg tutor-btn-block tutor-mt-24 tutor-add-to-cart-button <?php echo esc_attr( $required_loggedin_class ); ?>"> |
| 71 | <span class="btn-icon tutor-icon-cart-filled"></span> |
| 72 | <span><?php echo esc_html( $product->single_add_to_cart_text() ); ?></span> |
| 73 | </button> |
| 74 | </form> |
| 75 | <?php |
| 76 | echo apply_filters( 'tutor_add_to_cart_btn', ob_get_clean(), get_the_ID() ); //phpcs:ignore |
| 77 | } |
| 78 | } else { |
| 79 | ?> |
| 80 | <p class="tutor-alert-warning"> |
| 81 | <?php esc_html_e( 'Please make sure that your product exists and valid for this course', 'tutor' ); ?> |
| 82 | </p> |
| 83 | <?php |
| 84 | } |
| 85 |