• As the title says I’m having a hard time figuring out how to display:none to the .woobt-thumb if the product is a variable product.
    My variant selector already displays thumbnails. I do not need the .woobt-thumb anymore when the product is a variable product.
    It is taking up a lot of space.

    I still need .woobt-thumb if the add-together product is a simple product.

    Thank you!

Viewing 3 replies - 1 through 3 (of 3 total)
  • 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');
        } 
    }

    If you dont want to create a plugin, you can paste the following code into your functions.php file or use the Code Snippets plugin:

    add_action('init', 'hide_woobt_thumb');
    
    function hide_woobt_thumb() {
        global $product;
        if ( $product->get_type() == 'variable' ) { ?>
        <style>
           .woobt-thumb {
              display: none;
            }
        </style>
    <?php } 
    }
    • This reply was modified 2 years, 7 months ago by oweibor.
    • This reply was modified 2 years, 7 months ago by oweibor.

    @oweibor something is wrong with your function code.

    add_action('init', 'hide_woobt_thumb');
    
    function hide_woobt_thumb() {
        global $product;
        if ( $product-><strong>is</strong>_type() == 'variable' ) { ?> //is is also not working....
        <style>
           .woobt-thumb {
              display: none;
            }
        </style>
    <?php } 
    }
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘CSS to Hide .woobt-thumb if Variable Product’ is closed to new replies.