Override plugin’s variable.php file with your theme’s variable.php file.

You are here:
← All Topics

This article belongs to our plugin : Woocommerce Color or Image Variation Swatches

To override plugin’s variable.php with your theme’s variable.php.copy/paste variable.php file from plugins woocommerce/single-product/add-to-cart to somewhere in your theme and then you will need some code in your theme’s functions.php file that replaces theme’s variable.php file as default variable template. Here is such sample code. Replace the/path/of/your/plugin/variable.php with the path of your theme’s variable.php.

 

function wcva_use_theme_variable_template($template, $template_name, $template_path) {
    if (strstr($template, 'variable.php')) {
        $template = ''.get_template_directory().'/variable.php';
    }
  
    return $template;
}

add_action( 'woocommerce_locate_template', 'wcva_use_theme_variable_template', 10, 3 );

Here we are assuming that Variable.php file is located inside root folder of the plugin.

Sidebar