ultramel1987
ultramel1987

Reputation: 91

Woocommerce Product Gallery Slider

On single woocommerce product pages I am trying to add the product gallery slider navigation and also correct the thumbnails to display correctly.

I have added the theme support for the wc-product-gallery-slider as follows

<?php

add_action( 'after_setup_theme', 'cws_child_theme_setup' );
function cws_child_theme_setup() {
    load_child_theme_textdomain( 'orgafit', get_stylesheet_directory() . '/languages' );
}
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );
?>

Link to Single Product Page

Upvotes: 0

Views: 11803

Answers (1)

Abubaker
Abubaker

Reputation: 103

You can add the slider navigation using WordPress filters.

add_filter( 'woocommerce_single_product_carousel_options', 'cuswoo_update_woo_flexslider_options' );
/** 
 * Filer WooCommerce Flexslider options - Add Navigation Arrows
 */
function cuswoo_update_woo_flexslider_options( $options ) {

    $options['directionNav'] = true;

    return $options;
}

This will add slider navigation options on left and right. Then we just have to add CSS.

 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: '\f054';
    font-family: 'Font Awesome 5 Free';
    margin-right: 10px;
    font-size: 20px;   
    font-weight: bold;
}
a.flex-prev::before {
    visibility:visible;
    content: '\f053';
    font-family: 'Font Awesome 5 Free';   
    margin-left: 10px;
    font-size: 20px;
    font-weight: bold;
}
ul.flex-direction-nav li a {
    color: #ccc;
}
ul.flex-direction-nav li a:hover {
    text-decoration: none;
}

The a.flex-next::after and ::before uses Font Awesome content, so make sure you add this according to the Font Awesome version you're using.

Upvotes: 4

Related Questions