3 * Front page Product Slider Section
6 * @subpackage Shop Isle
9 $shop_isle_products_slider_hide = get_theme_mod( 'shop_isle_products_slider_hide', false );
10 if ( ! empty( $shop_isle_products_slider_hide ) && (bool) $shop_isle_products_slider_hide === true ) {
14 echo '<section class="home-product-slider">';
17 echo '<div class="container">';
20 if ( current_user_can( 'edit_theme_options' ) ) {
21 $shop_isle_products_slider_title = get_theme_mod( 'shop_isle_products_slider_title', __( 'Exclusive products', 'shop-isle' ) );
22 if ( ! class_exists( 'WC_Product' ) ) {
23 $shop_isle_products_slider_subtitle = get_theme_mod( 'shop_isle_products_slider_subtitle', __( 'For this section to work, you first need to install the WooCommerce plugin , create some products, and select a product category in Customize -> Frontpage sections -> Products slider section', 'shop-isle' ) );
25 $shop_isle_products_slider_subtitle = get_theme_mod( 'shop_isle_products_slider_subtitle' );
28 $shop_isle_products_slider_title = get_theme_mod( 'shop_isle_products_slider_title' );
29 $shop_isle_products_slider_subtitle = get_theme_mod( 'shop_isle_products_slider_subtitle' );
33 if ( ! empty( $shop_isle_products_slider_title ) || ! empty( $shop_isle_products_slider_subtitle ) ) :
34 echo '<div class="row">';
35 echo '<div class="col-sm-6 col-sm-offset-3">';
36 if ( ! empty( $shop_isle_products_slider_title ) ) :
37 echo '<h2 class="module-title font-alt home-prod-title">' . $shop_isle_products_slider_title . '</h2>';
39 if ( ! empty( $shop_isle_products_slider_subtitle ) ) :
40 echo '<div class="module-subtitle font-serif home-prod-subtitle">' . $shop_isle_products_slider_subtitle . '</div>';
43 echo '</div><!-- .row -->';
46 $shop_isle_products_slider_category = get_theme_mod( 'shop_isle_products_slider_category' );
49 $tax_query_item = array();
50 $meta_query_item = array();
52 if ( taxonomy_exists( 'product_visibility' ) ) {
53 $tax_query_item = array(
55 'taxonomy' => 'product_visibility',
57 'terms' => 'exclude-from-catalog',
58 'operator' => 'NOT IN',
62 $meta_query_item = array(
63 'key' => '_visibility',
69 $shop_isle_products_slider_args = array(
70 'post_type' => 'product',
71 'posts_per_page' => 10,
74 if ( ! empty( $shop_isle_products_slider_category ) && ( $shop_isle_products_slider_category != '-' ) ) {
75 $shop_isle_products_slider_args['tax_query'] = array(
77 'taxonomy' => 'product_cat',
79 'terms' => $shop_isle_products_slider_category,
84 if ( ! empty( $tax_query_item ) ) {
85 $shop_isle_products_slider_args['tax_query']['relation'] = 'AND';
86 $shop_isle_products_slider_args['tax_query'] = array_merge( $shop_isle_products_slider_args['tax_query'], $tax_query_item );
89 if ( ! empty( $meta_query_item ) ) {
90 $shop_isle_products_slider_args['meta_query'] = $meta_query_item;
95 if ( ! empty( $shop_isle_products_slider_category ) && ( $shop_isle_products_slider_category != '-' ) ) :
97 $shop_isle_products_slider_loop = new WP_Query( $shop_isle_products_slider_args );
99 if ( $shop_isle_products_slider_loop->have_posts() ) :
101 $rtl_slider = apply_filters( 'shop_isle_products_slider_section_rtl', 'false' );
102 $number_of_items = apply_filters( 'shop_isle_products_slider_section_items', 5 );
103 $pagination = apply_filters( 'shop_isle_products_slider_section_pagination', 'false' );
104 $navigation = apply_filters( 'shop_isle_products_slider_section_navigation', 'false' );
106 echo '<div class="row">';
108 echo '<div class="owl-carousel text-center" data-items="' . esc_attr( $number_of_items ) . '" data-pagination="' . esc_attr( $pagination ) . '" data-navigation="' . esc_attr( $navigation ) . '" data-rtl="' . esc_attr( $rtl_slider ) . '" >';
110 while ( $shop_isle_products_slider_loop->have_posts() ) :
112 $shop_isle_products_slider_loop->the_post();
114 echo '<div class="owl-item">';
115 echo '<div class="col-sm-12">';
116 echo '<div class="ex-product">';
117 if ( function_exists( 'woocommerce_get_product_thumbnail' ) ) :
118 echo '<a href="' . esc_url( get_permalink() ) . '">' . woocommerce_get_product_thumbnail() . '</a>';
120 echo '<h4 class="shop-item-title font-alt"><a href="' . esc_url( get_permalink() ) . '">' . get_the_title() . '</a></h4>';
122 if ( function_exists( 'method_exists' ) && ( function_exists( 'wc_get_rating_html' ) ) && method_exists( $product, 'get_average_rating' ) ) {
123 $shop_isle_avg = $product->get_average_rating();
124 if ( ! empty( $shop_isle_avg ) ) {
125 $rating_html = wc_get_rating_html( $shop_isle_avg );
127 } elseif ( function_exists( 'method_exists' ) && method_exists( $product, 'get_rating_html' ) && method_exists( $product, 'get_average_rating' ) ) {
128 $shop_isle_avg = $product->get_average_rating();
129 if ( ! empty( $shop_isle_avg ) ) {
130 $rating_html = $product->get_rating_html( $shop_isle_avg );
133 if ( ! empty( $rating_html ) && get_option( 'woocommerce_enable_review_rating' ) === 'yes' ) {
134 echo '<div class="product-rating-home">' . $rating_html . '</div>';
136 if ( function_exists( 'method_exists' ) && method_exists( $product, 'is_on_sale' ) ) {
137 if ( $product->is_on_sale() ) {
138 if ( function_exists( 'woocommerce_show_product_sale_flash' ) ) {
139 woocommerce_show_product_sale_flash();
143 if ( function_exists( 'method_exists' ) && method_exists( $product, 'managing_stock' ) && method_exists( $product, 'is_in_stock' ) ) {
144 if ( ! $product->managing_stock() && ! $product->is_in_stock() ) {
145 echo '<span class="onsale stock out-of-stock">' . esc_html__( 'Out of Stock', 'shop-isle' ) . '</span>';
148 $shop_isle_price = '';
149 if ( function_exists( 'method_exists' ) && method_exists( $product, 'get_price_html' ) ) {
150 $shop_isle_price = $product->get_price_html();
152 if ( ! empty( $shop_isle_price ) ) {
153 echo wp_kses_post( $shop_isle_price );
170 $shop_isle_products_slider_loop = new WP_Query( $shop_isle_products_slider_args );
172 if ( $shop_isle_products_slider_loop->have_posts() ) :
174 $rtl_slider = apply_filters( 'shop_isle_products_slider_section_rtl', 'false' );
175 $number_of_items = apply_filters( 'shop_isle_products_slider_section_items', 5 );
176 $pagination = apply_filters( 'shop_isle_products_slider_section_pagination', 'false' );
177 $navigation = apply_filters( 'shop_isle_products_slider_section_navigation', 'false' );
178 echo '<div class="row">';
180 echo '<div class="owl-carousel text-center" data-items="' . esc_attr( $number_of_items ) . '" data-pagination="' . esc_attr( $pagination ) . '" data-navigation="' . esc_attr( $navigation ) . '" data-rtl="' . esc_attr( $rtl_slider ) . '">';
182 while ( $shop_isle_products_slider_loop->have_posts() ) :
184 $shop_isle_products_slider_loop->the_post();
186 echo '<div class="owl-item">';
187 echo '<div class="col-sm-12">';
188 echo '<div class="ex-product">';
189 if ( function_exists( 'woocommerce_get_product_thumbnail' ) ) :
190 echo '<a href="' . esc_url( get_permalink() ) . '">' . woocommerce_get_product_thumbnail() . '</a>';
192 echo '<h4 class="shop-item-title font-alt"><a href="' . esc_url( get_permalink() ) . '">' . get_the_title() . '</a></h4>';
195 if ( function_exists( 'method_exists' ) && ( function_exists( 'wc_get_rating_html' ) ) && method_exists( $product, 'get_average_rating' ) ) {
196 $shop_isle_avg = $product->get_average_rating();
197 if ( ! empty( $shop_isle_avg ) ) {
198 $rating_html = wc_get_rating_html( $shop_isle_avg );
200 } elseif ( function_exists( 'method_exists' ) && method_exists( $product, 'get_rating_html' ) && method_exists( $product, 'get_average_rating' ) ) {
201 $shop_isle_avg = $product->get_average_rating();
202 if ( ! empty( $shop_isle_avg ) ) {
203 $rating_html = $product->get_rating_html( $shop_isle_avg );
206 if ( ! empty( $rating_html ) && get_option( 'woocommerce_enable_review_rating' ) === 'yes' ) {
207 echo '<div class="product-rating-home">' . $rating_html . '</div>';
209 if ( function_exists( 'method_exists' ) && method_exists( $product, 'is_on_sale' ) ) {
210 if ( $product->is_on_sale() ) {
211 if ( function_exists( 'woocommerce_show_product_sale_flash' ) ) {
212 woocommerce_show_product_sale_flash();
216 if ( function_exists( 'method_exists' ) && method_exists( $product, 'managing_stock' ) && method_exists( $product, 'is_in_stock' ) ) {
217 if ( ! $product->managing_stock() && ! $product->is_in_stock() ) {
218 echo '<span class="onsale stock out-of-stock">' . esc_html__( 'Out of Stock', 'shop-isle' ) . '</span>';
221 $shop_isle_price = '';
222 if ( function_exists( 'method_exists' ) && method_exists( $product, 'get_price_html' ) ) {
223 $shop_isle_price = $product->get_price_html();
225 if ( ! empty( $shop_isle_price ) ) {
226 echo wp_kses_post( $shop_isle_price );