Woocommerce child theme - overriding woocommerce support in child theme

314 Views Asked by At

I am using underscores as a parent theme. It declares Woocommerce support like this:

function _s_woocommerce_setup() {
add_theme_support(
    'woocommerce',
    array(
        'thumbnail_image_width' => 150,
        'single_image_width'    => 300,
        'product_grid'          => array(
            'default_rows'    => 3,
            'min_rows'        => 1,
            'default_columns' => 4,
            'min_columns'     => 1,
            'max_columns'     => 6,
        ),
    )
);
add_theme_support( 'wc-product-gallery-zoom' );
add_theme_support( 'wc-product-gallery-lightbox' );
add_theme_support( 'wc-product-gallery-slider' );

}

How do I remove or override the settings in a child theme. For instance, I want the thumbnail width to be 300px for the child theme. How is this achieved? Can I remove theme support and re-add it?

And to clarify I have unsucessfully tried this:

function remove_parent_settings(){
remove_theme_support( 'thumbnail_image_width' );
remove_theme_support( 'gallery_thumbnail_image_width' );
remove_theme_support( 'single_image_width' ); } 

And then

add_action( 'after_setup_theme', 'remove_parent_settings', 99 );
1

There are 1 best solutions below

1
On

Please add below code in child theme.

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

add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' );