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
65 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 | $args = array(); |
| 25 | $defaults = array( |
| 26 | 'quantity' => 1, |
| 27 | 'class' => implode( ' ', array_filter( array( |
| 28 | 'button', |
| 29 | 'product_type_' . $product->get_type(), |
| 30 | $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', |
| 31 | $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '', |
| 32 | ) ) ), |
| 33 | 'attributes' => array( |
| 34 | 'data-product_id' => $product->get_id(), |
| 35 | 'data-product_sku' => $product->get_sku(), |
| 36 | 'aria-label' => $product->add_to_cart_description(), |
| 37 | 'rel' => 'nofollow', |
| 38 | ), |
| 39 | ); |
| 40 | |
| 41 | $args = apply_filters( 'woocommerce_loop_add_to_cart_args', wp_parse_args( $args, $defaults ), $product ); |
| 42 | |
| 43 | if ( isset( $args['attributes']['aria-label'] ) ) { |
| 44 | $args['attributes']['aria-label'] = strip_tags( $args['attributes']['aria-label'] ); |
| 45 | } |
| 46 | |
| 47 | ?> |
| 48 | |
| 49 | <div class="tutor-loop-cart-btn-wrap"> |
| 50 | <?php |
| 51 | echo apply_filters( 'woocommerce_loop_add_to_cart_link', // WPCS: XSS ok. |
| 52 | sprintf( '<a href="%s" data-quantity="%s" class="%s" %s>%s</a>', |
| 53 | esc_url( $product->add_to_cart_url() ), |
| 54 | esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ), |
| 55 | esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ), |
| 56 | isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '', |
| 57 | esc_html( $product->add_to_cart_text() ) |
| 58 | ), |
| 59 | $product, $args ); |
| 60 | |
| 61 | ?> |
| 62 | |
| 63 | </div> |
| 64 | |
| 65 |