preset-1.php
164 lines
| 1 | <?php |
| 2 | /** |
| 3 | * Template Name: Preset 1 |
| 4 | */ |
| 5 | |
| 6 | use Essential_Addons_Elementor\Classes\Helper; |
| 7 | use Essential_Addons_Elementor\Elements\Woo_Product_List; |
| 8 | |
| 9 | if ( ! defined( 'ABSPATH' ) ) { |
| 10 | exit; |
| 11 | } // Exit if accessed directly |
| 12 | |
| 13 | if ( empty( $woo_product_list ) ) { |
| 14 | $woo_product_list = Woo_Product_List::get_woo_product_list_settings( $settings ); |
| 15 | } |
| 16 | |
| 17 | $product = wc_get_product( get_the_ID() ); |
| 18 | if ( ! $product ) { |
| 19 | error_log( '$product not found in ' . __FILE__ ); |
| 20 | return; |
| 21 | } |
| 22 | |
| 23 | $woo_product_list_loop = Woo_Product_List::get_woo_product_list_loop_settings( $product, $settings, $woo_product_list ); // static method as the template is used by read more feature too |
| 24 | ?> |
| 25 | <div <?php post_class( 'product' ); ?>> |
| 26 | <div class="eael-product-list-item <?php echo esc_attr( $woo_product_list['image_alignment'] ); ?>"> |
| 27 | <?php if( 'badge-preset-2' === $woo_product_list['badge_preset'] ) : ?> |
| 28 | <?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?> |
| 29 | <?php endif; ?> |
| 30 | |
| 31 | <div class="eael-product-list-image-wrap"> |
| 32 | <?php if( 'badge-preset-2' !== $woo_product_list['badge_preset'] ) : ?> |
| 33 | <?php Woo_Product_List::eael_print_produt_badge_html( $woo_product_list, $product ); ?> |
| 34 | <?php endif; ?> |
| 35 | |
| 36 | <?php if ( $woo_product_list['image_clickable'] ) : ?> |
| 37 | <a href="<?php echo esc_url( $product->get_permalink() ); ?>" class="woocommerce-LoopProduct-link woocommerce-loop-product__link" > |
| 38 | <?php endif; ?> |
| 39 | |
| 40 | <?php echo wp_kses_post( $product->get_image( $woo_product_list['image_size'], ['loading' => 'eager', 'alt' => $product->get_title() ] ) ); ?> |
| 41 | |
| 42 | <?php if ( $woo_product_list['image_clickable'] ) : ?> |
| 43 | </a> |
| 44 | <?php endif; ?> |
| 45 | |
| 46 | <?php if ( $woo_product_list['button_position_on_hover'] ) : ?> |
| 47 | <ul class="eael-product-list-buttons-on-hover"> |
| 48 | <?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?> |
| 49 | <li class="eael-product-list-add-to-cart-button eael-m-0"> |
| 50 | <?php woocommerce_template_loop_add_to_cart(); ?> |
| 51 | </li> |
| 52 | <?php endif; ?> |
| 53 | |
| 54 | <?php if ( $woo_product_list['quick_view_button_show'] ) : ?> |
| 55 | <li class="eael-product-list-quick-view-button eael-m-0"> |
| 56 | <a id="eael_quick_view_<?php echo esc_attr( uniqid() ); ?>" data-quickview-setting="<?php echo esc_attr( htmlspecialchars( json_encode( $woo_product_list_loop['quick_view_setting'] ), ENT_QUOTES ) ); ?>" class="open-popup-link"><i class="fas fa-eye"></i></a> |
| 57 | </li> |
| 58 | <?php endif; ?> |
| 59 | |
| 60 | <?php if ( $woo_product_list['link_button_show'] ) : ?> |
| 61 | <li class="eael-product-list-link-button eael-m-0"> |
| 62 | <a href="<?php echo esc_url( $product->get_permalink() ); ?>"><i class="fas fa-link"></i></a> |
| 63 | </li> |
| 64 | <?php endif; ?> |
| 65 | </ul> |
| 66 | <?php endif; ?> |
| 67 | </div> |
| 68 | |
| 69 | <div class="eael-product-list-content-wrap"> |
| 70 | <?php |
| 71 | if ( 'after-title' === $woo_product_list['content_header_position'] ) : |
| 72 | Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product ); |
| 73 | endif; |
| 74 | ?> |
| 75 | |
| 76 | <div class="eael-product-list-content-header <?php echo esc_attr( $woo_product_list_loop['direction_rtl_class'] ) ?>" > |
| 77 | <?php if ( $woo_product_list['rating_show'] ) : ?> |
| 78 | <div class="eael-product-list-rating"> |
| 79 | <?php |
| 80 | $avg_rating = $product->get_average_rating(); |
| 81 | if( $avg_rating > 0 ){ |
| 82 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 83 | echo wc_get_rating_html( $avg_rating, $product->get_rating_count()); |
| 84 | } else { |
| 85 | // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped |
| 86 | echo Helper::eael_rating_markup( $avg_rating, $product->get_rating_count() ); |
| 87 | } |
| 88 | ?> |
| 89 | |
| 90 | <?php if ( $woo_product_list['review_count_show'] && $woo_product_list_loop['review_count'] > 0 ) : ?> |
| 91 | <a href="<?php echo esc_url( get_permalink() ) ?>#reviews" class="woocommerce-review-link eael-product-list-review-count" rel="nofollow">(<?php printf( '%s', esc_html__( $woo_product_list_loop['review_count'], 'essential-addons-for-elementor-lite' ) ); ?>)</a> |
| 92 | <?php endif; ?> |
| 93 | </div> |
| 94 | <?php endif; ?> |
| 95 | |
| 96 | <div class="eael-product-list-notice eael-product-list-notice-shiping-free"> |
| 97 | <?php if ( $woo_product_list['category_show'] && $woo_product_list_loop['has_terms'] ) : ?> |
| 98 | <p> |
| 99 | <i class="fas fa-box"></i> |
| 100 | <?php echo esc_html( Woo_Product_List::eael_get_product_category_name( $woo_product_list_loop['terms'] ) ); ?> |
| 101 | </p> |
| 102 | <?php endif; ?> |
| 103 | </div> |
| 104 | </div> |
| 105 | <div class="eael-product-list-content-body"> |
| 106 | <?php |
| 107 | if ( 'before-title' === $woo_product_list['content_header_position'] ) : |
| 108 | Woo_Product_List::eael_print_product_title_html( $woo_product_list, $product ); |
| 109 | endif; |
| 110 | ?> |
| 111 | |
| 112 | <?php if ( $woo_product_list['excerpt_show'] ) : ?> |
| 113 | <div class="eael-product-list-excerpt"> |
| 114 | <?php |
| 115 | if( $woo_product_list['excerpt_words_count'] ){ |
| 116 | $content = wp_trim_words( strip_shortcodes( get_the_excerpt() ), $woo_product_list['excerpt_words_count'], $woo_product_list['excerpt_expanison_indicator'] ); |
| 117 | echo esc_html( $content ); |
| 118 | } else { |
| 119 | echo wp_kses( get_the_excerpt(), Helper::eael_allowed_tags() ); |
| 120 | } |
| 121 | ?> |
| 122 | </div> |
| 123 | <?php endif; ?> |
| 124 | |
| 125 | <?php if ( $woo_product_list['price_show'] ) : ?> |
| 126 | <h3 class="eael-product-list-price"> |
| 127 | <?php echo wp_kses_post( $product->get_price_html() ); ?> |
| 128 | </h3> |
| 129 | <?php endif; ?> |
| 130 | </div> |
| 131 | <div class="eael-product-list-content-footer"> |
| 132 | <?php if ( $woo_product_list['total_sold_show'] ) : ?> |
| 133 | <div class="eael-product-list-progress"> |
| 134 | <div class="eael-product-list-progress-info"> |
| 135 | <h4 class="eael-product-list-progress-count"><?php esc_html_e( $woo_product_list['total_sold_text'], 'essential-addons-for-elementor-lite' ); ?> <span><?php echo esc_html( $woo_product_list_loop['total_sales_count'] ); ?></span></h4> |
| 136 | <?php if( $product->managing_stock() && $woo_product_list['total_sold_remaining_show'] ) : ?> |
| 137 | <h4 class="eael-product-list-progress-remaining"><?php esc_html_e( $woo_product_list['total_sold_remaining_text'], 'essential-addons-for-elementor-lite' ); ?> <span><?php echo esc_html( $woo_product_list_loop['stock_quantity_count'] ); ?></span></h4> |
| 138 | <?php endif; ?> |
| 139 | </div> |
| 140 | <div class="eael-product-list-progress-bar-outer"> |
| 141 | <div style="width: <?php echo esc_attr( $woo_product_list_loop['total_sold_progress_percentage'] ); ?>%;" class="eael-product-list-progress-bar-inner"></div> |
| 142 | </div> |
| 143 | </div> |
| 144 | <?php endif; ?> |
| 145 | |
| 146 | <?php if ( $woo_product_list['button_position_static'] ) : ?> |
| 147 | <div class="eael-product-list-buttons"> |
| 148 | <?php if ( $woo_product_list['add_to_cart_button_show'] ) : ?> |
| 149 | <p class="eael-product-list-add-to-cart-button eael-m-0"><?php woocommerce_template_loop_add_to_cart(); ?></p> |
| 150 | <?php endif; ?> |
| 151 | |
| 152 | <?php if ( $woo_product_list['quick_view_button_show'] ) : ?> |
| 153 | <p class="eael-product-list-quick-view-button eael-m-0"> |
| 154 | <a id="eael_quick_view_<?php echo esc_attr( uniqid() ); ?>" data-quickview-setting="<?php echo esc_attr( htmlspecialchars( json_encode( $woo_product_list_loop['quick_view_setting'] ), ENT_QUOTES ) ); ?>" class="open-popup-link"> |
| 155 | <?php esc_html_e( $woo_product_list['quick_view_text'], 'essential-addons-for-elementor-lite' ); ?> |
| 156 | </a> |
| 157 | </p> |
| 158 | <?php endif; ?> |
| 159 | </div> |
| 160 | <?php endif; ?> |
| 161 | </div> |
| 162 | </div> |
| 163 | </div> |
| 164 | </div> |