• You MUST read the Babiato Rules before making your first post otherwise you may get permanent warning points or a permanent Ban.

    Our resources on Babiato Forum are CLEAN and SAFE. So you can use them for development and testing purposes. If your are on Windows and have an antivirus that alerts you about a possible infection: Know it's a false positive because all scripts are double checked by our experts. We advise you to add Babiato to trusted sites/sources or disable your antivirus momentarily while downloading a resource. "Enjoy your presence on Babiato"

Hide select options from products on pages and shop

Tom_Sanchez

Member
Jun 28, 2019
70
30
18
Hi guys, would like to know if someone can help here... I would like to hide the select options options label that is being shown on products pages. Please see attached...
 

Attachments

  • Opera Snapshot_2020-10-25_233925_www.masvaporworldwide.com.png
    Opera Snapshot_2020-10-25_233925_www.masvaporworldwide.com.png
    265.4 KB · Views: 7
Found the CSS Variable and add it to css to get rid of it, but it also get rid the add to cart if someone use it!

}
.woocommerce .products .product_type_variable {
display: none !important;
}
 

Attachments

  • Opera Snapshot_2020-10-26_130209_www.masvaporworldwide.com.png
    Opera Snapshot_2020-10-26_130209_www.masvaporworldwide.com.png
    208.8 KB · Views: 2
You have to add some code to your child theme's functions.php file (or use a plugin like My Custom Functions).

Add this:
PHP:
add_filter( 'woocommerce_loop_add_to_cart_link', function( $product ) {
 
    global $product;
 
    if ( is_shop() && 'variable' === $product->product_type ) {
        return '';
    } else {
        sprintf( '<a href="%s" data-quantity="%s" class="%s" %s>%s</a>',
            esc_url( $product->add_to_cart_url() ),
            esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
            esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ),
            isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
            esc_html( $product->add_to_cart_text() )
        );
    }
 
} );

After you added the above, select options are gone, but the button 'Add to Cart' is still there.
 
  • Like
Reactions: Tom_Sanchez
You have to add some code to your child theme's functions.php file (or use a plugin like My Custom Functions).

Add this:
PHP:
add_filter( 'woocommerce_loop_add_to_cart_link', function( $product ) {

    global $product;

    if ( is_shop() &amp;&amp; 'variable' === $product->product_type ) {
        return '';
    } else {
        sprintf( '<a href="%s" data-quantity="%s" class="%s" %s>%s</a>',
            esc_url( $product->add_to_cart_url() ),
            esc_attr( isset( $args['quantity'] ) ? $args['quantity'] : 1 ),
            esc_attr( isset( $args['class'] ) ? $args['class'] : 'button' ),
            isset( $args['attributes'] ) ? wc_implode_html_attributes( $args['attributes'] ) : '',
            esc_html( $product->add_to_cart_text() )
        );
    }

} );

After you added the above, select options are gone, but the button 'Add to Cart' is still there.
In my case I do not want any of those to show up on the front. but will try this code and will let you know, also will try the plugin you mention!
 

Latest posts

Forum statistics

Threads
79,275
Messages
1,138,117
Members
247,729
Latest member
accnopro
AdBlock Detected

We get it, advertisements are annoying!

However in order to keep our huge array of resources free of charge we need to generate income from ads so to use the site you will need to turn off your adblocker.

If you'd like to have an ad free experience you can become a Babiato Lover by donating as little as $5 per month. Click on the Donate menu tab for more info.

I've Disabled AdBlock