How To Change WooCommerce Add To Cart Button Text

WooCommerce is not a one size fits all solution. Sometimes the default options just don’t suit your needs and you need to make slight modifications, via code or template edits, to accomplish your goals.

For this example, let’s pretend you sell eyeglass frames, and the words “Add To Cart” just don’t sound trendy enough for you and instead you want it to say “Buy Now”. What can we do?

You’re in luck — Changing the add to cart button text in WooCommerce is made super easy by hooking into the woocommerce_product_single_add_to_cart_text and woocommerce_product_add_to_cart_text filters provided by the plugin.

You can find a full WooCommerce hook reference here.

The following snippets of code can be used inside functions.php to change the default “Add To Cart” text.

Quick Links

Single Product Pages

Use this snippet if you only want to change the text on single product pages:

add_filter('woocommerce_product_single_add_to_cart_text', 'my_custom_cart_text_single');
 
function my_custom_cart_text_single() {
    return __("Buy Now", "woocommerce");
}

Product Archives

Use this snippet if you only want to change the text on archive pages:

add_filter('woocommerce_product_add_to_cart_text', 'my_custom_cart_text_archive');
 
function my_custom_cart_text_archive() {
    return __("Buy Now", "woocommerce");
}

Specific Products

Use this snippet if you only want to change the text for specific product IDS:

add_filter('woocommerce_product_add_to_cart_text', 'my_custom_cart_text_per_product');
 
function my_custom_cart_text_per_product($default_text) {
    // put your product IDs in this array
    $product_ids = array(4,8,15,16,23,42);

    if (in_array(get_the_ID(), $product_ids)) {
        return __('Get This Deal', 'woocommerce');
    }

    return $default_text;
}

Specific Product Types

Use this snippet if you only want to change the text for specific product types:

add_filter('woocommerce_product_single_add_to_cart_text', 'my_custom_cart_text_single_product_type');

function my_custom_cart_text_single_product_type($default_text)
{
    global $product;
    
    $product_type = $product->product_type;
    
    switch ($product_type) {
        case 'external':
            return __('Visit Site', 'woocommerce');
            break;
        case 'grouped':
            return __('See Offer', 'woocommerce');
            break;
        case 'simple':
            return __('Click Here To Purchase', 'woocommerce');
            break;
        case 'variable':
            return __('See All Options', 'woocommerce');
            break;
        default:
            return $default_text;
    }
}

Specific Product Categories

Use this snippet if you want to change the text for specific product categories:

add_filter('woocommerce_product_single_add_to_cart_text', 'my_custom_cart_text_single_product_category');

function my_custom_cart_text_single_product_category($default_text)
{
    global $post;

    $product_categories = array(4,8,15,16,23,42);    
    $terms = get_the_terms($post->ID, 'product_cat');

    foreach ($terms as $term) {
        if (in_array($term->term_id, $product_categories)) {
            return __('Get Offer', 'woocommerce');
        }
    }

    return $default_text;    
}

Conclusion

Now that you know several different ways we can change the default Add to Cart button text in WooCommerce you can challenge yourself further by coming up with some additional use cases where you’d want to change text. See how many you can come up with and share them with me if you come up with something not listed here.