Created
April 22, 2022 08:24
-
-
Save bradleysa/f72bd558d5e8e7ffe5213a396991ad0f to your computer and use it in GitHub Desktop.
WC: Change 'add to cart' text on single product category
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
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