Created
July 29, 2012 22:32
-
-
Save ChromeOrange/3202257 to your computer and use it in GitHub Desktop.
Replace all add to cart button text
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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. | |
} | |
?> |
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
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: