Tom_Sanchez
Member
- Jun 28, 2019
- 55
- 17
- 8
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() )
);
}
} );
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!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.