Created
July 31, 2015 12:14
-
-
Save woogist/8a200b55f6b785b4b4e8 to your computer and use it in GitHub Desktop.
Change the "Add to Cart" text on the single product page based on the product ID
This file contains hidden or 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
/** | |
* Change the "Add to Cart" text on the single product page based on the product ID | |
* | |
* @param string $text | |
* @param object $product | |
* @return string | |
*/ | |
function wc_custom_single_addtocart_text( $text, $product ) { | |
$products = array( 1, 2, 3 ); | |
if ( in_array( $product->id, $products) ) { | |
$text = 'Special text'; | |
} | |
return $text; | |
} | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'wc_custom_single_addtocart_text', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment