Hello Builders,
I’m using WC module displaying featured products and I want to change the “add to cart” button behavior. I would like to change href of button to take the user to product page.
I’m using this code below, the href property change but the button still adding product to cart.
Please, any thoughts about what I need to do will be appreciated.
/**
* Alterar destino do botão principal Adicionar ao carrinho
*
* @since 1.0.0
*/
add_filter( 'woocommerce_loop_add_to_cart_link', 'dl_alterar_destino_botao' );
function dl_alterar_destino_botao( $product ) {
global $product;
return sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" data-quantity="%s" class="button %s product_type_%s">COMPRAR</a>',
esc_url( get_permalink( $product->id ) ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
esc_attr( isset( $quantity ) ? $quantity : 1 ),
$product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '',
esc_attr( $product->product_type )
);
}
Site: http://181.224.144.163/dentalliberdade/
WP version: 4.3
WC version: 2.4.4
BB plugin version: 1.6
BB theme version: 1.3.1.2
Thanks!