Created
October 27, 2021 14:52
-
-
Save joychetry/d63c5178bd247d5f486c14c21d72b4c3 to your computer and use it in GitHub Desktop.
Change WooCommerce Add To Cart Texts
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 | |
add_filter( 'add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // < 2.1 | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_single_add_to_cart_text' ); // 2.1 + | |
function woo_custom_single_add_to_cart_text() { | |
return __( 'My Button Text', 'woocommerce' ); | |
} | |
add_filter( 'add_to_cart_text', 'woo_custom_product_add_to_cart_text' ); // < 2.1 | |
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_product_add_to_cart_text' ); // 2.1 + | |
function woo_custom_product_add_to_cart_text() { | |
return __( 'My Button Text', 'woocommerce' ); | |
} | |
// Alter WooCommerce View Cart Text | |
add_filter( 'gettext', function( $translated_text ) { | |
if ( 'View cart' === $translated_text ) { | |
$translated_text = 'Your new text here'; | |
} | |
return $translated_text; | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment