';
if ( current_user_can( 'edit_theme_options' ) ) {
$shop_isle_products_title = get_theme_mod( 'shop_isle_products_title', __( 'Latest products', 'shop-isle' ) );
} else {
$shop_isle_products_title = get_theme_mod( 'shop_isle_products_title' );
}
if ( ! empty( $shop_isle_products_title ) ) :
echo '
';
echo '
';
echo '
' . $shop_isle_products_title . '
';
echo '';
echo '
';
endif;
$shop_isle_products_shortcode = get_theme_mod( 'shop_isle_products_shortcode' );
$shop_isle_products_category = get_theme_mod( 'shop_isle_products_category' );
/* Woocommerce shortcode */
if ( isset( $shop_isle_products_shortcode ) && ! empty( $shop_isle_products_shortcode ) ) :
echo '
';
echo do_shortcode( $shop_isle_products_shortcode );
echo '
';
/* Products from category */
elseif ( isset( $shop_isle_products_category ) && ! empty( $shop_isle_products_category ) && ( $shop_isle_products_category != '-' ) ) :
$shop_isle_latest_args = array(
'post_type' => 'product',
'posts_per_page' => 8,
'orderby' => 'date',
'order' => 'DESC',
'tax_query' => array(
array(
'taxonomy' => 'product_cat',
'field' => 'term_id',
'terms' => $shop_isle_products_category,
),
),
'meta_query' => array(
array(
'key' => '_visibility',
'value' => 'hidden',
'compare' => '!=',
),
),
);
$shop_isle_latest_loop = new WP_Query( $shop_isle_latest_args );
if ( $shop_isle_latest_loop->have_posts() ) :
echo '
';
while ( $shop_isle_latest_loop->have_posts() ) :
$shop_isle_latest_loop->the_post();
global $product;
echo '
';
echo '
';
echo '
';
$shop_isle_gallery_attachment_ids = false;
if ( class_exists( 'WC_Product' ) ) {
$shop_isle_gallery_attachment_ids = $product->get_gallery_attachment_ids();
}
if ( has_post_thumbnail( $shop_isle_latest_loop->post->ID ) ) :
echo get_the_post_thumbnail( $shop_isle_latest_loop->post->ID, 'shop_catalog' );
if ( $shop_isle_gallery_attachment_ids ) :
echo wp_get_attachment_image( $shop_isle_gallery_attachment_ids[0], 'shop_catalog' );
endif;
elseif ( $shop_isle_gallery_attachment_ids ) :
if ( $shop_isle_gallery_attachment_ids[0] ) :
echo wp_get_attachment_image( $shop_isle_gallery_attachment_ids[0], 'shop_catalog' );
endif;
if ( $shop_isle_gallery_attachment_ids[1] ) :
echo wp_get_attachment_image( $shop_isle_gallery_attachment_ids[1], 'shop_catalog' );
endif;
else :
if ( function_exists( 'wc_placeholder_img_src' ) ) :
echo '
![Placeholder](' . esc_url( wc_placeholder_img_src() ) . ')
';
endif;
endif;
echo '
';
if ( ! empty( $product ) ) :
echo do_shortcode( '[add_to_cart id="' . $shop_isle_latest_loop->post->ID . '"]' );
if ( function_exists( 'wccm_add_button' ) ) {
wccm_add_button();
}
if ( defined( 'YITH_WCQV' ) ) {
echo '
' . __( 'Quick View', 'shop-isle' ) . '';
}
endif;
echo '
';
echo '
';
echo '
';
$rating_html = '';
if ( function_exists( 'method_exists' ) && method_exists( $product, 'get_rating_html' ) && method_exists( $product, 'get_average_rating' ) ) {
$shop_isle_avg = $product->get_average_rating();
if ( ! empty( $shop_isle_avg ) ) {
$rating_html = $product->get_rating_html( $shop_isle_avg );
}
}
if ( ! empty( $rating_html ) && get_option( 'woocommerce_enable_review_rating' ) === 'yes' ) {
echo '
' . $rating_html . '
';
}
if ( function_exists( 'method_exists' ) && method_exists( $product, 'is_on_sale' ) ) {
if ( $product->is_on_sale() ) {
if ( function_exists( 'woocommerce_show_product_sale_flash' ) ) {
woocommerce_show_product_sale_flash();
}
}
}
if ( function_exists( 'method_exists' ) && method_exists( $product, 'managing_stock' ) && method_exists( $product, 'is_in_stock' ) ) {
if ( ! $product->managing_stock() && ! $product->is_in_stock() ) {
echo '
' . esc_html__( 'Out of Stock', 'shop-isle' ) . '';
}
}
$shop_isle_price = '';
if ( function_exists( 'method_exists' ) && method_exists( $product, 'get_price_html' ) ) {
$shop_isle_price = $product->get_price_html();
}
if ( ! empty( $shop_isle_price ) ) {
echo wp_kses_post( $shop_isle_price );
}
echo '
';
echo '
';
endwhile;
echo '
';
echo '
';
else :
echo '
';
echo '
';
echo '
' . __( 'No products found.', 'shop-isle' ) . '
';
echo '
';
echo '
';
endif;
wp_reset_postdata();
/* Latest products */
else :
$shop_isle_latest_args = array(
'post_type' => 'product',
'posts_per_page' => 8,
'orderby' => 'date',
'order' => 'DESC',
'meta_query' => array(
array(
'key' => '_visibility',
'value' => 'hidden',
'compare' => '!=',
),
),
);
$shop_isle_latest_loop = new WP_Query( $shop_isle_latest_args );
if ( $shop_isle_latest_loop->have_posts() ) :
echo '
';
while ( $shop_isle_latest_loop->have_posts() ) :
$shop_isle_latest_loop->the_post();
global $product;
echo '
';
echo '
';
echo '
';
$shop_isle_gallery_attachment_ids = false;
if ( class_exists( 'WC_Product' ) ) {
$shop_isle_gallery_attachment_ids = $product->get_gallery_attachment_ids();
}
if ( has_post_thumbnail( $shop_isle_latest_loop->post->ID ) ) :
echo get_the_post_thumbnail( $shop_isle_latest_loop->post->ID, 'shop_catalog' );
if ( $shop_isle_gallery_attachment_ids ) :
echo wp_get_attachment_image( $shop_isle_gallery_attachment_ids[0], 'shop_catalog' );
endif;
elseif ( $shop_isle_gallery_attachment_ids ) :
if ( $shop_isle_gallery_attachment_ids[0] ) :
echo wp_get_attachment_image( $shop_isle_gallery_attachment_ids[0], 'shop_catalog' );
endif;
if ( $shop_isle_gallery_attachment_ids[1] ) :
echo wp_get_attachment_image( $shop_isle_gallery_attachment_ids[1], 'shop_catalog' );
endif;
else :
if ( function_exists( 'wc_placeholder_img_src' ) ) :
echo '
![Placeholder](' . esc_url( wc_placeholder_img_src() ) . ')
';
endif;
endif;
echo '
';
echo '
';
echo '
';
$rating_html = '';
if ( function_exists( 'method_exists' ) && method_exists( $product, 'get_rating_html' ) && method_exists( $product, 'get_average_rating' ) ) {
$shop_isle_avg = $product->get_average_rating();
if ( ! empty( $shop_isle_avg ) ) {
$rating_html = $product->get_rating_html( $shop_isle_avg );
}
}
if ( ! empty( $rating_html ) && get_option( 'woocommerce_enable_review_rating' ) === 'yes' ) {
echo '
' . $rating_html . '
';
}
if ( function_exists( 'method_exists' ) && method_exists( $product, 'is_on_sale' ) ) {
if ( $product->is_on_sale() ) {
if ( function_exists( 'woocommerce_show_product_sale_flash' ) ) {
woocommerce_show_product_sale_flash();
}
}
}
if ( function_exists( 'method_exists' ) && method_exists( $product, 'managing_stock' ) && method_exists( $product, 'is_in_stock' ) ) {
if ( ! $product->managing_stock() && ! $product->is_in_stock() ) {
echo '
' . esc_html__( 'Out of Stock', 'shop-isle' ) . '';
}
}
$shop_isle_price = '';
if ( function_exists( 'method_exists' ) && method_exists( $product, 'get_price_html' ) ) {
$shop_isle_price = $product->get_price_html();
}
if ( ! empty( $shop_isle_price ) ) {
echo wp_kses_post( $shop_isle_price );
}
echo '
';
echo '
';
endwhile;
echo '
';
echo '
';
elseif ( current_user_can( 'edit_theme_options' ) ) :
echo '
';
echo '
';
echo '
' . __( 'For this section to work, you first need to install the WooCommerce plugin , create some products, and insert a WooCommerce shortocode or select a product category in Customize -> Frontpage sections -> Products section', 'shop-isle' ) . '
';
echo '
';
echo '
';
endif;
wp_reset_postdata();
endif;
echo '
';
echo '';