How to Edit See Details,More details or Buy Now Button and Change Texts From WooCommerce Products Category Page

Here is how to replace the "Buy Now" buttons with a "See Details" button on your category pages and make the "See Details" button link to the product page instead of the merchant's website. Here is how our categories looks before our code changes :



Now you need to add the following code to your custom code file . you can add it in your theme functions.php file. Here is codes :
<?php

/**
* Removes the "Buy" button from list of products (ex. category pages).
*/
add_action( 'woocommerce_after_shop_loop_item', 'mycode_remove_add_to_cart_buttons', 1 );
function mycode_remove_add_to_cart_buttons() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart' );
}

/**
* Adds a "See Details" button on list of products (ex. category pages).
*/
add_action( 'woocommerce_after_shop_loop_item', 'mycode_add_more_info_buttons', 1 );
function mycode_add_more_info_buttons() {
add_action( 'woocommerce_after_shop_loop_item', 'mycode_more_info_button' );
}

function mycode_more_info_button() {
global $product;
echo '<a href="' . get_permalink( $product->id ) . '" class="button add_to_cart_button product_type_external">See Details</a>';
}
After you make the change, your category pages will look like this :



Comments