WooCommerce: Change Add To Cart Text

WooCommerce change add to cart text

WooCommerce is a very flexible plugin that allows you to customize your site. In some scenarios, you may be able to change the “Add To Cart” text using an option that your theme provides.

However, in other cases, you may be using a theme or a page builder plugin like Elementor or Divi that may not allow you to change it easily in the admin area.

Thankfully, there is a quick and easy way to change it with a little bit of code, even if you’re not a WooCommerce developer yourself.

How To Change The WooCommerce “Add To Cart” Text With Custom Code

First of all, you will need to add a bit of php code to your site. There are 2 main ways to do it.


Method #1: Edit the functions.php file of your child theme.
Remember not to add it to the parent theme because these changes will be lost when you update your theme. You can either edit this file by connecting to your server via FTP and editing it, OR by going to Appearance -> Theme Editor -> Selecting your child theme -> Editing the functions.php file:

Edit functions.php file of your child theme

Method #2: Using a plugin that allows adding custom code like the CodeSnippets plugin for example.

Code Snippets: add custom code (part 1)
Code Snippets: add custom code (part 2)

Now that we know where to add the code, let’s see what code we need to add.

There 2 places where we need to change the “Add to cart” text: on the shop/product listing page and on the single product page.

The following code snippet will change the text from “Add to cart” to “Buy” on both pages:

// Change add to cart text on single product page
add_filter('woocommerce_product_single_add_to_cart_text', 'change_add_to_cart_text_on_single_product_page');

function change_add_to_cart_text_on_single_product_page() {
    return __('Buy', 'woocommerce'); // Change 'Buy' to whatever you want the text to say
}

// Change add to cart text on shop page
add_filter('woocommerce_product_add_to_cart_text', 'change_add_to_cart_text_on_shop_page');

function change_add_to_cart_text_on_shop_page() {
    return __('Buy', 'woocommerce');
}

All you need to do is to add this code snippet to your child theme’s functions.php file (ideally at the very end) or to the Code Snippets plugin.

About The Author

Andriy Haydash

Andriy Haydash

Andriy Haydash is a WordPress Expert who helps people build and launch successful WordPress membership and e-learning websites.

Note: Not all of the articles are written directly by me.
Affiliate Disclaimer: Some links in the post may be my affiliate links

The Ultimate Managed Hosting Platform

Before YOU Leave...
Join My Newsletter

Get practical tips & tricks on how to start, grow and market your course/membership site.