Skip to main content

The “Add to Cart” button text in WooCommerce is one of the most visible elements of any online store. However, the default text might not align with your brand, or you may want to test alternatives like “Buy Now” or “Get Yours Today” to see if they resonate better with customers. In this post, we’ll show you how to change the “Add to Cart” text in WooCommerce with a simple code snippet.

Why Change the “Add to Cart” Text?

Customizing the “Add to Cart” text can make your store feel unique and can also influence your customers’ purchasing decisions. For example, using a more direct call to action, such as “Buy Now,” can create a sense of urgency that encourages more immediate purchases.

Adding the Custom Code to Change “Add to Cart” Text

To change the “Add to Cart” text, you’ll need to add a custom code snippet to your theme’s functions.php file or by using a code snippet plugin like Code Snippets if you prefer not to directly modify theme files.

Important Note: Always back up your site before making changes to theme files, as mistakes could lead to errors.

Step 1: Change the “Add to Cart” Text on Product Pages

If you want to change the “Add to Cart” text that appears on individual product pages, add the following code to your functions.php file or through a code snippet plugin:

// Change "Add to Cart" text on single product pages
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_single_add_to_cart_text' );

function custom_single_add_to_cart_text() {
return ‘Buy Now’; // Replace ‘Buy Now’ with your desired text
}

This code snippet changes the “Add to Cart” text on single product pages to “Buy Now.” You can replace 'Buy Now' with any phrase you prefer.

Step 2: Change the “Add to Cart” Text on Shop Pages

If you also want to change the text on shop archive pages (like category pages or the main shop page), use the following code:

// Change "Add to Cart" text on archive (shop) pages
add_filter( 'woocommerce_product_add_to_cart_text', 'custom_archive_add_to_cart_text' );

function custom_archive_add_to_cart_text() {
return ‘Add to Bag’; // Replace ‘Add to Bag’ with your desired text
}

With this code snippet, the “Add to Cart” button on archive pages will say “Add to Bag” (or any phrase you specify).

Step 3: Customizing Text for Different Product Types

If you want to display different “Add to Cart” text based on the product type, such as variable products or external products, you can use the following code:

// Customize "Add to Cart" text based on product type
add_filter( 'woocommerce_product_add_to_cart_text', 'custom_product_type_add_to_cart_text' );

function custom_product_type_add_to_cart_text( $text ) {
global $product;
if ( $product->is_type( ‘simple’ ) ) {
return ‘Add to Cart’; // Change for simple products
} elseif ( $product->is_type( ‘variable’ ) ) {
return ‘Choose Options’; // Change for variable products
} elseif ( $product->is_type( ‘external’ ) ) {
return ‘Buy Now’; // Change for external products
}
return $text;
}

This snippet customizes the text based on the product type, allowing for targeted messaging across different products in your store.

Step 4: Save and Test

After adding your desired code snippet, make sure to save the changes, clear your site cache if applicable, and refresh your site. Check the product and shop pages to see your new button text in action.