1
votes

Woocommerce took out the option for enabling a lightbox feature for your image gallery earlier this year. They have in their documentation to add code if you want to enable the gallery features but don’t actually say where.

https://woocommerce.wordpress.com/2017/02/28/adding-support-for-woocommerce-2-7s-new-gallery-feature-to-your-theme/

This is a significant frontend change that can be broken down in to three separate new features; • Image zoom / magnification • Lightbox • Slider To enable each of these features in your theme you must declare support using add_theme_support() like so:

    add_action( 'after_setup_theme', 'yourtheme_setup' );

function yourtheme_setup() {
    add_theme_support( 'wc-product-gallery-zoom' );
    add_theme_support( 'wc-product-gallery-lightbox' );
    add_theme_support( 'wc-product-gallery-slider' );
}

This allows you the flexibility to pick and choose exactly which features you want to include/exclude in your theme or at your store.

I am not a developer, I don’t have a developer (and shame on WC for not making this an option that end users can opt for or not without having to add code!)

I need to know where to put this code. I am using a child theme called mystile1. I have files called “Theme Functions (function.php)” and one called “custom.css” that’s says it is specifically for adding code to modify my child theme styles.

I don’t know which file I should put the above coding in and where. Nowhere does each of these files have a line called “after_setup_theme” So would I be safe in just adding the code as follows in one of those files (which one?) replacing “yourtheme” with the name of my theme:

add_action( 'after_setup_theme', 'mystile1_setup' );

function mystile1_setup() {
    add_theme_support( 'wc-product-gallery-zoom' );
    add_theme_support( 'wc-product-gallery-lightbox' );
    add_theme_support( 'wc-product-gallery-slider' );
}

Or any other suggestions are greatly appreciated.

Thank you.

IN RESPONSE:

Below is what is in my functions.php file. would I put the code at the top in between new brackets or down in the section that says: /-----------------------------------------------------------------------------------/ /* You can add custom functions below / /-----------------------------------------------------------------------------------*/

function mystile1_setup() {
    add_theme_support( 'wc-product-gallery-zoom' );
    add_theme_support( 'wc-product-gallery-lightbox' );
    add_theme_support( 'wc-product-gallery-slider' );
}
?>

"MY FUNCTIONS.PHP FILE" INCLUDES

<?php
// File Security Check
if ( ! empty( $_SERVER['SCRIPT_FILENAME'] ) && basename( __FILE__ ) ==     basename( $_SERVER['SCRIPT_FILENAME'] ) ) {
    die ( 'You do not have sufficient permissions to access this page!' );
}
?>
<?php

/-----------------------------------------------------------------------------------/ /* Start WooThemes Functions - Please refrain from editing this section / /-----------------------------------------------------------------------------------*/

// Define the theme-specific key to be sent to PressTrends.
define( 'WOO_PRESSTRENDS_THEMEKEY', 'zdmv5lp26tfbp7jcwiw51ix9sj389e712' );

// WooFramework init
require_once ( get_template_directory() . '/functions/admin-init.php' );

/-----------------------------------------------------------------------------------/ /* Load the theme-specific files, with support for overriding via a child theme. /-----------------------------------------------------------------------------------/

$includes = array(
                'includes/theme-options.php',           // Options panel     settings and custom settings
                'includes/theme-functions.php',         // Custom theme functions
                'includes/theme-actions.php',           // Theme actions & user defined hooks
                'includes/theme-comments.php',          // Custom comments/pingback loop
                'includes/theme-js.php',                // Load JavaScript via wp_enqueue_script
                'includes/sidebar-init.php',            // Initialize widgetized areas
                'includes/theme-widgets.php',           // Theme widgets
                'includes/theme-install.php',           // Theme installation
                'includes/theme-woocommerce.php'        // WooCommerce options
            );

// Allow child themes/plugins to add widgets to be loaded.

$includes = apply_filters( 'woo_includes', $includes );

foreach ( $includes as $i ) {
    locate_template( $i, true );
}

/-----------------------------------------------------------------------------------/ /* You can add custom functions below / /-----------------------------------------------------------------------------------*/

// CUSTOM FUNCTION ADDED TO ADDRESS LACK OF ADD-TO-CART BUTTONS ON VARIABLE ITEMS
// AS DOCUMENTED AT: http://wordpress.org/support/topic/plugin-woocommerce-excelling-ecommerce-checkout-button-not-showing-on-woo-commerce-product/page/2?replies=36#post-3263097

function mv_my_theme_scripts() { wp_enqueue_script('add-to-cart-variation', get_template_directory_uri() . '/js/add-to-cart-variation.js',array('jquery'),'1.0',true); } add_action('wp_enqueue_scripts','mv_my_theme_scripts');

/-----------------------------------------------------------------------------------/ /* Don't add any code below here or the sky will fall down / /-----------------------------------------------------------------------------------*/ ?>`

1
you need to put this code in function.php file, which reside in your theme folderBalwant

1 Answers

0
votes

You have to put the code in your function.php between <?php and ?> tags.

As additional note: you can put all of these gallery' effects or only few of them on your site. For example if performance of your site is degrading you can delete or put // to

add_theme_support( 'wc-product-gallery-zoom' );

or to other effects.