Last active
July 17, 2021 04:07
-
-
Save frankschrijvers/2575f5f662de313a639b2dcfa890d36c to your computer and use it in GitHub Desktop.
Set WooCommerce product button text to productname
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 | |
//* Do NOT include the opening php tag shown above. Copy the code shown below. | |
add_filter( 'woocommerce_product_single_add_to_cart_text', 'wps_custom_cart_button_text' ); | |
/** | |
* Set product button text to productname | |
*/ | |
function wps_custom_cart_button_text() { | |
global $product; | |
$id = get_the_ID(); | |
$title = get_the_title( $id ); | |
return __( 'buy ' . $title, 'your_theme_text_domain' ); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment