Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Created July 29, 2012 22:32
Show Gist options
  • Star 7 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save ChromeOrange/3202257 to your computer and use it in GitHub Desktop.
Save ChromeOrange/3202257 to your computer and use it in GitHub Desktop.
Replace all add to cart button text
<?php
// Single Product
add_filter( 'single_add_to_cart_text', 'custom_single_add_to_cart_text' );
function custom_single_add_to_cart_text() {
return 'Add to cart'; // Change this to change the text on the Single Product Add to cart button.
}
// Variable Product
add_filter( 'variable_add_to_cart_text', 'custom_variable_add_to_cart_text' );
function custom_variable_add_to_cart_text() {
return 'Select options'; // Change this to change the text on the Variable Product button.
}
// Grouped Product
add_filter( 'grouped_add_to_cart_text', 'custom_grouped_add_to_cart_text' );
function custom_grouped_add_to_cart_text() {
return 'View options'; // Change this to change the text on the Grouped Product button.
}
// External Product
add_filter( 'external_add_to_cart_text', 'custom_external_add_to_cart_text' );
function custom_external_add_to_cart_text() {
return 'Read More'; // Change this to change the text on the External Product button.
}
// Default
add_filter( 'add_to_cart_text', 'custom_add_to_cart_text' );
function custom_add_to_cart_text() {
return 'Add to cart'; // Change this to change the text on the Default button.
}
?>
@CHEWX
Copy link

CHEWX commented Jul 2, 2018

I know this is 6 years old, but for those falling upon this, it is now out of date.

Couple updates I've used:

single_add_to_cart_text => woocommerce_product_single_add_to_cart_text
add_to_cart_text => woocommerce_product_add_to_cart_text

@AlamiAbdessalam
Copy link

AlamiAbdessalam commented Nov 2, 2018

u are a legend CHEWX , thanks a lot.

Am using this code if anyone want it and it works :

add_filter('woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text',1);
function woo_custom_cart_button_text() {
return __('Your Text Button', 'woocommerce');
}

@jeremycaris
Copy link

Thanks to the original code and previous comments with updates, I was able to put something together that is working. This is the only thing that worked for me:

add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_single_add_to_cart_text' );
function custom_single_add_to_cart_text() {
	return 'Add To Cart';
}

@vittoria-thomasini
Copy link

u are a legend CHEWX , thanks a lot.

Am using this code if anyone want it and it works :

add_filter('woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text',1);
function woo_custom_cart_button_text() {
return __('Your Text Button', 'woocommerce');
}

Thanks, that works for me. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment