Skip to content

Instantly share code, notes, and snippets.

@joychetry
Created October 27, 2021 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save joychetry/d63c5178bd247d5f486c14c21d72b4c3 to your computer and use it in GitHub Desktop.
Save joychetry/d63c5178bd247d5f486c14c21d72b4c3 to your computer and use it in GitHub Desktop.
Change WooCommerce Add To Cart Texts
<?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