[wd_asp elements=’search’ ratio=’100%’ id=1]

Change ‘Add to cart’ button to ‘View Product’ in Woocommerce

26th September 2020

WooCommerce

woocommerce category codehaven

Changing the button text to read ‘View Product’ in Woocommerce

In this case I have changed it to “Have a Look”…

// Replace add to cart button by a linked button to the product in Shop and archives pages
add_filter( 'woocommerce_loop_add_to_cart_link', 'replace_loop_add_to_cart_button', 10, 2 );
function replace_loop_add_to_cart_button( $button, $product ) {
// Not needed for variable products
if( $product->is_type( 'variable' ) ) return $button;

// Button text here
$button_text = __( "Have a Look", "woocommerce" );

return '' . $button_text . '';
}