Display woocommerc shop page Gallery item

<style>

flex-control-thumbs {
width: 90%;
position: absolute;
bottom: 0px;
text-align: center;
display:flex;
flex-wrap:nowrap;

border: 1px solid red;
overflow-x:auto;
padding-bottom:10px;
}

.flex-control-thumbs li {
margin: 0 6px;
display: inline-block;
zoom: 1;
}


.flex-control-thumbs li,
.flex-control-thumbs li:first-child {
width: 10%;
vertical-align: top;
margin: 5px 1% 0 0;
min-width: 60px;
}

.flex-control-thumbs img {
width: 100%;
display: block;
opacity: 0.8;
cursor: pointer;
}

.flex-control-thumbs img:hover {
opacity: 0.5;
}

.flex-control-thumbs .flex-active {
opacity: 1;
cursor: default;
}

.product_slider .flex-active-slide a:hover {
cursor: -webkit-zoom-in;
cursor: -moz-zoom-in;
}


ul.flex-direction-nav {
position: absolute;
top: 30%;
z-index: 99999;
width: 100%;
left: 0;
margin: 0;
padding: 0px;
list-style: none;}

li.flex-nav-prev {float: left;}
li.flex-nav-next {float: right;}
a.flex-next {visibility:hidden;}
a.flex-prev {visibility:hidden;}
a.flex-next::after {visibility:visible;content: '\f105';
font-family: FontAwesome;margin-right: 10px;font-size: 70px; }
a.flex-prev::before {
visibility:visible;
content: '\f104';
font-family: FontAwesome; margin-left: 10px;font-size: 70px;
</style>

add_action('woocommerce_shop_loop_item_title','wps_add_extra_product_thumbs', 15);
function wps_add_extra_product_thumbs() {

if ( is_shop() ) {

global $product;

$attachment_ids = $product->get_gallery_attachment_ids();
wp_enqueue_script('flexslider');
echo '<div class="flexslider"><ul class="flex-control-nav flex-control-thumbs product-thumbs slides">';

foreach( array_slice( $attachment_ids, 0,3 ) as $attachment_id ) {


$thumbnail_url = wp_get_attachment_image_src( $attachment_id, 'thumbnail' )[0];

echo '<li data-thumb="' . $thumbnail_url . '">';
echo '<img src="' . $thumbnail_url . '">';
echo '</li>';


}

echo '</ul></div>';

}

}

Leave a comment