Istiaq Nirab full stack + ai
← Writing
WooCommerce Sep 22, 2023

WooCommerce : Change product's add-to-cart button text

Change the add-to-cart button text of WooCommerce products with plugins or with two filter hooks.

No code solutions

You can easily do this with these Free Plugins

Coding Solutions

To change product text, You’ll need to use two filter hooks

woocommerce_product_single_add_to_cart_text

This hook is defined in woocommerce/includes/class-wc-product-external.php:171 and used to filter out add_to_cart button text value for single page only.

	/**
	 * Get the add to cart button text for the single page.
	 *
	 * @access public
	 * @return string
	 */
	public function single_add_to_cart_text() {
		return apply_filters( 
		  'woocommerce_product_single_add_to_cart_text', 
		  $this->get_button_text() ? 
		      $this->get_button_text() :
		       _x( 'Buy product', 'placeholder', 'woocommerce' ), 
		  $this 
		);
	}

Have 2-parameters

  1. Actual Add to Cart Button text
  2. Product Object

To change add_to_cart across all type of products list, You’ll need to use this hook :

woocommerce_product_add_to_cart_text

This hook is also defined in the same file as the previous hook.

	/**
	 * Get the add to cart button text.
	 *
	 * @access public
	 * @return string
	 */
	public function add_to_cart_text() {
		return apply_filters( 
		  'woocommerce_product_add_to_cart_text', 
		  $this->get_button_text() ? 
		    $this->get_button_text() : 
		    _x( 'Buy product', 'placeholder', 'woocommerce' ), 
		  $this 
		);
	}

also contains 2 parameters like the last hook.

Let’s see some examples.

All Products

<?php

// Change add to cart text on single product page
add_filter( 
  'woocommerce_product_single_add_to_cart_text', 
  'change_button_text_single' 
); 
function change_button_text_single($text) {
    return __( 'Buy Now', 'text-domain' ); 
}

// Change add to cart text on product list page
add_filter( 
  'woocommerce_product_add_to_cart_text', 
  'change_button_text_lists' 
);  
function change_button_text_lists($text) {
    return __( 'Buy Now', 'text-dmain' );
}

Only Simple Products

<?php

// Change add to cart text on single product page
add_filter( 
'woocommerce_product_single_add_to_cart_text', 
'change_button_text_single', 10, 2 ); 
function change_button_text_single($text, $product) {
    if ( "simple" === $product->get_type() ) {
      return __( 'Buy Now', 'text-domain' );
    } 
    
    return $text;
}

// Change add to cart text on product list page
add_filter( 
  'woocommerce_product_add_to_cart_text', 
  'change_button_text_lists', 10, 2 );  
function change_button_text_lists($text, $product) {
    if ( "simple" === $product->get_type() ) {
      return __( 'Buy Now', 'text-domain' );
    } 
    
    return $text;
}

Only Digital products

First, We need to check if the product is virtual. If the product is virtual then just return the Text else return the default text.

// Change add to cart text on single product page
add_filter(
  'woocommerce_product_single_add_to_cart_text', 
  'change_button_text_single', 10, 2);
function change_button_text_single($text, $product)
{
    // check if product is virtual
    if (true === $product->get_meta('_virtual')) {
        return __('Get Now', 'text-domain');
    }

    return $text;
}

// Change add to cart text on product list page
add_filter(
  'woocommerce_product_add_to_cart_text', 
  'change_button_text_lists', 10, 2);
function change_button_text_lists($text, $product)
{
    // check if product is virtual
    if (true === $product->get_meta('_virtual')) {
        return __('Get Now', 'text-domain');
    }

    return $text;
}

Thanks.

Discussion

Comments run on giscus, backed by GitHub Discussions — sign in with GitHub to reply.

More posts
Networking

TCP: how a connection actually works

What TCP does on top of IP: ports, the three-way handshake, sequence numbers, ACKs, retransmission, closing a connection, and the costs that pushed HTTP/3 onto QUIC.

2026-09-26
NLP

Vectorizing text: from word counts to meaning

How text becomes numbers a model can work with: one-hot vectors, bag of words, TF-IDF, the hashing trick, word embeddings and sentence embeddings, and when to use each.

2026-09-25
Networking

The OSI model, layer by layer

What each of the seven OSI layers does, how one HTTPS request gets wrapped and unwrapped on the way to a server, and why switches, routers and load balancers stop at different layers.

2026-09-16
ContactGMT+6

Have something that needs building, fixing, or finishing? Write one paragraph — that's usually enough.

open to new work
Local time--:--:--
Based inDhaka, BD
Experience6+ years