Website Building » WooCommerce » How Do I Change the Add to Cart Button Text and Link in WooCommerce?

How Do I Change the Add to Cart Button Text and Link in WooCommerce?

Last updated on January 23, 2023 @ 12:15 pm

When you first install WooCommerce, the default “Add to Cart” button text is “Add to cart”. If you want to change the button text, there are two ways to do it.

The first way is to use a plugin like WooCommerce Custom Add to Cart Button. This plugin lets you change the button text for each product individually. To use this plugin, install and activate it, then go to WooCommerce > Settings > Add to Cart Buttons and enter your custom text in the “Button Text” field.

The second way is to change the button text globally by adding some code to your child theme’s functions.php file or a custom plugin. Paste the following code into your functions.php file:

PRO TIP: The following instructions are for changing the add to cart button text and link in WooCommerce. Please note that this will only work if you have a child theme activated. If you do not have a child theme activated, your changes will be lost when you update the WooCommerce plugin.
function wc_custom_add_to_cart_text() {
  return __( 'My custom text', 'woocommerce' );
}
add_filter( 
  'woocommerce_product_add_to_cart_text', 
  'wc_custom_add_to_cart_text' );

This code will change the button text on all products to “My custom text”. You can change “My custom text” to anything you like. If you want to change the button text for specific products, you can use conditional tags like this:

function wc_custom_add_to_cart_text() {
  global $product;
 
   if ( $product->is_type( 'variable' ) ) {
     return __( 'Select options', 'woocommerce' ); 
     // variable product button text  
     return __( 'Read more', 'woocommerce' ); 
     // other product types button text 
   } 
   else { 
     return __( 'Add to cart', 'woocommerce' ); 
   } 
} 
add_filter( 
  'woocommerce_product_add_to_cart_text', 
  'wc_custom_addTo cart _text' );

The first line of this code changes the button text on variable products to “Select options”. The second line changes the button text on all other product types to “Read more”. You can change these texts to anything you like.

Conclusion:

There are two ways that you can go about changing the Add To Cart button text in WooCommerce. The first way is by using a plugin and the second way is by adding some code snippets. If you want to change the button text globally, then add some code to your child theme’s functions.

Dale Leydon

Dale Leydon

Sysadmin turned Javascript developer. Owner of 20+ apps graveyard, and a couple of successful ones.