How to Remove "Select Option" from Variable Products on Woocommerce Shop Page or Product Loop Page

How to Remove “Select Options” from Variable Products on Woocommerce Shop Page or Product Loop Page

by emuslearner
0 comment

By default, WooCommerce added a “Select Options” button on the main shop page or product category pages for variable products. In this post, I’ll show how you can remove the button.

Just add the code to your theme function.php file

// Remove "Select options" button from (variable) products on WooCommerce shop page or category pages.
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() )
		);
	}

} );
0 comment

More Posts in this topic

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

//onvictinitor.com/afu.php?zoneid=3046762
%d bloggers like this: