JOIN THE NS CLUB AND SAVE OVER $850 !

How to change the text of the Add to cart button?

For your e-commerce site you would like to change the item of the “Add to cart” button. The reasons can be different: for example, in starting a non-profit, beneficial business you may not like too commercial a text.

In other contexts, there is an extreme need to customize this item and to understand how to change the text of the Add to cart button.

There are those who intend to change it to facilitate or improve the shopping experience and those who are simply tired of using the usual standard and default wordings.

Regardless of individual needs, you can change the text of the Add to Cart button of WooCommerce by directly editing the text string files of the plugin in use.

However, this is not the best way to proceed. Making changes in this way would risk canceling them every time the plugin is updated.

What to do? Is there a quick and easy way to change the Add to Cart button text?

How to edit the text of the Add to cart button: try using a snippet

The snippet is a simple addition to the theme functions file you are using (functions.php). With the snippet you can change the text of the Add to Cart or Buy Now buttons within the individual product pages.You will only need to edit the “Custom Button Text” string. The codes must be inserted in the theme’s functions.php file by making changes and customizations in the pages of the individual products, always using the child theme to avoid losing the changes with the template updates.Before choosing a snippet, check the compatibility with WooCommerce in a fairly updated version, let’s say from 3.2.1 up.With a few lines of code you can add a touch of originality to your Add to cart button by changing the wording.Here are a couple of examples referring to version 3.2.1 of WooCommerce.

A couple of examples to edit the text with the snippet

The first example is suitable for those who want to intervene on the button text of each product displayed in the categories or archive pages.

You will need to open the functions.php file of the theme in use with a text editor. You can find it in the FTP space of your WordPress site (wp-content / themes / {name_of_thema} /).

Here you can enter the following snippet to get the change:

 

// Change the text of the buy button in the loop

add_filter (‘woocommerce_product_add_to_cart_text’, function ($ text, $ product) {

return __ (‘Add to cart’, ‘woocommerce’);

}, 10, 2);

 

If, on the other hand, you want to change the text of the Add to cart button only on the page of a single product, you must proceed in this way.

Opening the functions.php file of your theme as we explained before, add this snippet:

 

// Change the text of the purchase button on the individual product page

add_filter (‘woocommerce_product_single_add_to_cart_text’, function ($ text, $ product) {

return __ (‘Add to cart’, ‘woocommerce’);

}, 10, 2);

 

Done!

Customize the text of the Add to cart button for each type of product

To get a different button text for each type of product, you will need to slightly change the snippets that we described above by entering a different condition.

You will only have to change the last part of the code (return __ (‘Add to cart’, ‘woocommerce’);

}, 10, 2);

replacing ‘Add to cart!’ with a text of your choice.

In this way, you will get different labels for the various types of products for sale in your e-commerce.

Nice effort, however, to change one product at a time …

Despite the various tips and the various online guides that explain in detail how to change the text of the Add to cart button, many users are unable to solve or solve only in part.

Most of the time, the snippet insertion system does not work with variable products or if there is an image to be added.

Other users don’t even try and look for a simple, possibly automatic, system to change the button text.

Is there a faster and simpler system?

Yes, it exists. It’s called “Custom add to cart button” and it’s a plugin of NS Themes.

Custom add to cart button: the NS Themes plugin for custom modification of the “Add to cart” button

The “Custom add to cart button” plugin developed by NS Themes allows you to easily change the text of the “Add to cart” button.The Page option appears in the WordPress back-end menu and this is where you can add the text of your button. Just type in the text and save it.The text of the new button will be displayed both on the online store page and in that of the single product.You can add new button text to your WooCommerce in an extremely simple and clean way.Here are the requirements for this plugin: WordPress 4.3 + WooCommerce 2.5.0 + PHP5.3 +With “Custom add to cart button” you have the possibility to:- add different button text for each product;- add different button text for each product category;- customize the style for any button.You can test the functions of the plugin by trying the free version.An annual license entitles you to one year of updates and support.The subscription will automatically renew every year until it is canceled.

 

Leave a Reply

Your email address will not be published.

X

Stay in touch

Suscribe to our newsletter for reserved offers and new updates

Accept our Term and Conditions and Privacy policy