It may be the case that the Add to cart button text does not suit your product or web shop. With a few lines of code you can easily change this text. In this short tutorial, I will show you how. You can adjust the Add to cart button text for the whole WooCommerce web shop, or for a single category only.
Change add to cart button text
To change the button text, add the following snippet to your theme’s functions.php
With this snippet, you can easily change the Add to cart button text on single pages into (for instance) Buy Product. If you want to adjust the button text on archive pages as well, you additionally have to add the following snippet to your theme’s functions.php.
Change add to cart button text per category
But … what if you want to change the button text for only one or two categories? No worries, I’ve got that covered too.
First thing, you have to locate the slugs of the categories you want to change the text for. Navigate to Products > Categories. In this example, I use the slug of the category clothing.
Next, you have to add this snippet to your functions.php. On line 19, you see that I’ve added the slug clothing. When an article is in the category with the slug clothing, the button text will be Order your Clothes. The default text will be Order now.
Using this snippet, you are able to change the Add to cart button text on single pages into Order your Clothes. If you also want to change the button text on archive pages, you additionally have to add the following snippet to your theme’s functions.php.
Change add to cart button text for more then one category
It’s possible to add a unique order button for every category. To do that, simply extent the snippets above with extra ‘cases’, such as hoodies and music.
That’s all, folks. I hope it’ll be useful for one of your upcoming projects.
jsk says
What is your-theme-text-domain ? is that the slug for my theme? thanks!
Frank Schrijvers says
The Text Domain is normally set in your theme’s functions.php. You need a Text Domain for translations. For more information about Text Domains have a look at the WordPress codex.
Sam says
Hi Frank
How do I change the text of the button underneath the product in the product category to the name of the product itself? It currently just says view product for underneath each product.
Frank Schrijvers says
Hey Sam,
I wrote a small tutorial, maybe this helps: http://www.wpstud.io/change-add-cart-button-text-product-name/
Frank
Scott says
Hi Frank,
This does not seem to work for the way we do it.
Instead of WC products, we use custom posts in which we put the “add to cart” button by placing this code:
[add_to_cart sku="book386" style="border:0px; padding:0px;" show_price="false"]
The button still shows “add to cart”
We sell books, and all will have 1, 2 or 3 editions, (hard, soft, ebook).
Do you know if there’s a way to change the button text for each edition to read “Hard cover”, Soft cover, or eBook based on the way we are doing it above?
Thanks,
Scott
Frank Schrijvers says
This function does not apply to shortcodes.