Skip to content

Instantly share code, notes, and snippets.

@bradleysa
Created April 22, 2022 08:24
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 bradleysa/f72bd558d5e8e7ffe5213a396991ad0f to your computer and use it in GitHub Desktop.
Save bradleysa/f72bd558d5e8e7ffe5213a396991ad0f to your computer and use it in GitHub Desktop.
WC: Change 'add to cart' text on single product category
add_filter( 'woocommerce_product_add_to_cart_text', 'product_cat_add_to_cart_button_text', 20, 1 );
function product_cat_add_to_cart_button_text( $text ) {
// Only for a specific product category
if( has_term( array('gift-pack'), 'product_cat' ) )
$text = __( 'Yes! The Perfect Gift!', 'woocommerce' );
return $text;
}
add_filter( 'woocommerce_product_single_add_to_cart_text', 'product_cat_single_add_to_cart_button_text', 20, 1 );
function product_cat_single_add_to_cart_button_text( $text ) {
// Only for a specific product category
if( has_term( array('gift-pack'), 'product_cat' ) )
$text = __( 'Yes! The Perfect Gift!', 'woocommerce' );
return $text;
}
/** https://stackoverflow.com/a/48354999 **/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment