add-to-cart-edd.php
6 years ago
add-to-cart-woocommerce.php
6 years ago
course-author.php
6 years ago
course-price-edd.php
6 years ago
course-price-woocommerce.php
6 years ago
course-price.php
6 years ago
course.php
6 years ago
end_content_wrap.php
6 years ago
footer.php
6 years ago
header.php
6 years ago
loop-after-content.php
6 years ago
loop-before-content.php
6 years ago
loop-end.php
6 years ago
loop-start.php
6 years ago
meta.php
6 years ago
rating.php
6 years ago
start_content_wrap.php
6 years ago
thumbnail.php
6 years ago
title.php
6 years ago
tutor-pagination.php
6 years ago
add-to-cart-woocommerce.php
80 lines
| 1 | <?php |
| 2 | /** |
| 3 | * A single course loop add to cart |
| 4 | * |
| 5 | * @since v.1.0.0 |
| 6 | * @author themeum |
| 7 | * @url https://themeum.com |
| 8 | * |
| 9 | * @package TutorLMS/Templates |
| 10 | * @version 1.4.3 |
| 11 | */ |
| 12 | |
| 13 | if ( ! defined( 'ABSPATH' ) ) { |
| 14 | exit; |
| 15 | } |
| 16 | |
| 17 | $product_id = tutor_utils()->get_course_product_id(); |
| 18 | $product = wc_get_product($product_id); |
| 19 | |
| 20 | if (! $product_id || ! $product){ |
| 21 | return; |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Add required loggedin class |
| 26 | * @since v 1.5.5 |
| 27 | */ |
| 28 | $isLoggedIn = is_user_logged_in(); |
| 29 | $enable_guest_course_cart = tutor_utils()->get_option('enable_guest_course_cart'); |
| 30 | $required_loggedin_class = ''; |
| 31 | $ajax_add_to_cart_class = ''; |
| 32 | if ( ! $isLoggedIn && ! $enable_guest_course_cart){ |
| 33 | $required_loggedin_class = apply_filters('tutor_enroll_required_login_class', 'cart-required-login'); |
| 34 | } else { |
| 35 | $ajax_add_to_cart_class = $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : ''; |
| 36 | } |
| 37 | |
| 38 | $args = array(); |
| 39 | $defaults = array( |
| 40 | 'quantity' => 1, |
| 41 | 'class' => implode( ' ', array_filter( array( |
| 42 | 'button', |
| 43 | 'product_type_' . $product->get_type(), |
| 44 | $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', |
| 45 | $ajax_add_to_cart_class, |
| 46 | $required_loggedin_class |
| 47 | ) ) ), |
| 48 | 'attributes' => array( |
| 49 | 'data-product_id' => $product->get_id(), |
| 50 | 'data-product_sku' => $product->get_sku(), |
| 51 | 'aria-label' => $product->add_to_cart_description(), |
| 52 | 'rel' => 'nofollow', |
| 53 | ), |
| 54 | ); |
| 55 | |
| 56 | $args = apply_filters( 'woocommerce_loop_add_to_cart_args', wp_parse_args( $args, $defaults ), $product ); |
| 57 | |
| 58 | if ( isset( $args['attributes']['aria-label'] ) ) { |
| 59 | $args['attributes']['aria-label'] = strip_tags( $args['attributes']['aria-label'] ); |
| 60 | } |
| 61 | |
| 62 | ?> |
| 63 | |
| 64 | <div class="tutor-loop-cart-btn-wrap"> |
| 65 | <?php |
| 66 | echo apply_filters( 'woocommerce_loop_add_to_cart_link', // WPCS: XSS ok. |
| 67 | sprintf( '<a href="%s" data-quantity="%s" class="%s" %s>%s</a>', |
| 68 | esc_url( $product->add_to_cart_url() ), |
| 69 | esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ), |
| 70 | esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ), |
| 71 | isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '', |
| 72 | esc_html( $product->add_to_cart_text() ) |
| 73 | ), |
| 74 | $product, $args ); |
| 75 | |
| 76 | ?> |
| 77 | |
| 78 | </div> |
| 79 | |
| 80 |