Woocommerce WordPress shop categories display different types of products with different buttons, like Select Options, More Info and Add to Cart. I wanted to have all this buttons to be the same, something like “More Info”. This can be done from functions.php
of my child theme.
To replace default “Add to Cart” button with i.e. More Info link put this code into your functions.php
file.
/* replace add to cart text on button */ add_filter('add_to_cart_text', 'woo_custom_cart_button_text'); function woo_custom_cart_button_text() { return __('More Info', 'woocommerce'); } /* remove add to cart class */ add_filter('add_to_cart_class', 'woo_custom_cart_button_class'); function woo_custom_cart_button_class() { return __('more_info_button', 'woocommerce'); } /* make all products go to product page */ add_filter( 'add_to_cart_url', 'woo_more_info_link' ); function woo_more_info_link( $link ) { global $product; // switches link in all cases, i.e. in plugins $link = get_permalink( $product->id ); return $link; }
We must remove add to cart class, if not, it will add the product to cart.
Now all buttons will have the same link to a product’s page, and you can also replace their text to be the same. There are some plugins that can help, or just add to your functions.php
for i.e. variable products:
/* change text on variable products */ add_filter('variable_add_to_cart_text', 'woo_custom_cart_button_text1'); function woo_custom_cart_button_text1() { return __('More Info', 'woocommerce'); }
With some additional CSS tweaks all buttons of your product boxes in a category page loop can be the same now.
Thank you – Thank you! I have been looking for this solution for months!
Its not working when I update to new woocommerce to version 2.1.
What I need to change it to make it working..? Please help.. Thankss
Yes no longer working in WooCommerce version 2.1, please help!
Change
to
Hy Ryan, that works for change the text only. When I click the button its still add to cart..
This one below is not working now. Hope somebody can help.. π
how about this? π π
Using the last method with “this is the magic”, it changes the button to text. Do you have a method to keep the button for the link?
You can check following code, that may help you π
The last solution still changes the button to a link π How can it be kept as a button?
Found the solution on this page
Hi,
I just like to know how to disable the add to cart function, so i don’t want it to be removed from the page, but only that if you click it, it doesn’t get the product added to the cart.
This code didn’t work. Anyone that can tell me the right code?
Complete solution (from above)
That last link should be:
I have a “Select Options” button on my category page. When I added a variable product, is then added a variable product options drop down under the “Select Options” button. I want to remove the variable options drop down and only have the “Select Options” button that takes user to product page. How do I remove the drop down?
I have seen that most of the store owners got confused while removing or disable the add to cart button. Now for any shop page or product you can remove the the add 2 cart button. You just have to follow these simple steps. In woocommerce.php (located wp-content/plugins/woocommerce)
Reference: https://www.wpblog.com/add-to-cart-button-in-woocommerce-store/