Basically, You want to display .woobt-thumb when the product is simple, but hide it when its variable. To make this Straightforward, I’ll create a plugin.
STEPS
********************************
1. Create a plugin folder called hide-woobt-thumb
2. Navigate to the folder, and create a file called hide-woobt-thumb.php
3. Also, create a sub-folder called css
then create/add your various stylesheets simple_style.css
and varible_style.css
. Ensure that you add the respective CSS display parameters to the corresponding CSS files.
4. Paste the code below into the hide-woobt-thumb.php
file located in the plugin’s root directory.
5. Upload and activate the plugin
/**
* Plugin Name: WOOBT
* Plugin URI: https://www.remarpro.com
* Description: Plugin to conditionally select stylesheet based on product type.
* Version: 1.0
* Requires at least: 5.2
* Requires PHP: 7.2
* Author: Nancy Pelosi (Wallstreet's Grandma)
* Author URI: https://author.example.com/
* License: GPL v2 or later
* License URI: https://www.gnu.org/licenses/gpl-2.0.html
* Update URI: https://yourwebsite.com/my-plugin/
*/
add_action('init', 'hide_woobt_thumb')
function hide_woobt_thumb(){
global $product;
wp_register_style('hide_varible_style', plugins_url('css/varible_style.css', __FILE__ ));
wp_register_style('show_simple_style', plugins_url('css/simple_style.css', __FILE__ ));
if ( $product->get_type() == 'variable' ) {
wp_enqueue_style('hide_varible_style');
}
if ($product->get_type() == 'simple') {
wp_enqueue_style('show_simple_style');
}
}