phpwordpresswoocommerceproductflexslider

How to Change FlexSlider options in WooCommerce child theme


I have just changed this part of class-wc-frontend-scripts.php file which is available in "includes" folder of Woocommerce:

'flexslider' => apply_filters( 'woocommerce_single_product_carousel_options',
    array(
        'rtl'            => is_rtl(),
        'animation'      => 'fade',
        'easing'      => 'swing',
        'smoothHeight'   => true,
        'directionNav'   => false,
        'controlNav'     => true,
        'slideshow'      => true,
        'touch'      => true,
        'animationSpeed' => 1200,
        'slideshowSpeed' => 3500,
        'animationLoop'  => true, // Breaks photoswipe pagination if true.
        'allowOneSlide'  => true,
        'prevText' => "<",           //String: Set the text for the "previous" directionNav item
        'nextText' => ">",               //String: Set the text for the "next" directionNav item
    )
),

How can I transfer it to child theme?


Solution

  • Don't override any core files… Instead you can use woocommerce_single_product_carousel_options filter hook as follow:

    add_filter( 'woocommerce_single_product_carousel_options', 'filter_single_product_carousel_options' );
    function filter_single_product_carousel_options( $args ) {
        $args['animation']      = 'fade';
        $args['easing']         = 'swing';
        $args['controlNav']     = true;
        $args['slideshow']      = true;
        $args['touch']          = true;
        $args['animationSpeed'] = 1200;
        $args['slideshowSpeed'] = 3500;
        $args['animationLoop']  = true; // Breaks photoswipe pagination if true.
        $args['allowOneSlide']  = true;
        $args['prevText']       = "<";  // String - Set the text for the "previous" directionNav item
        $args['nextText']       = ">";  // String - Set the text for the "next" directionNav item
        
        return $args;
    }
    

    Code goes in functions.php file of your active child theme (or active theme). It should work.

    Related: Change FlexSlider options on mobile in Woocommerce