Skip to content

Instantly share code, notes, and snippets.

@ChromeOrange
Created July 29, 2012 22:32
Show Gist options
  • 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.
}
?>
@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