Hi Support,
How can I amend the following filter so that it only applies to a single product id, for example: 21314
add_filter( ‘woocommerce_product_single_add_to_cart_text’, ‘woo_custom_cart_button_text’ );
function woo_custom_cart_button_text() {
return __( ‘My Button Text’, ‘woocommerce’ );
}
Source: https://kriesi.at/support/topic/how-to-change-add-to-cart-button-text-to-buy-now/#post-663957
Thanks in advance
Hey Paul,
Here is the code you can put in your funtions.php
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' );
function woo_custom_cart_button_text() {
if (get_the_ID() == '21314') {
return __( 'My Button Text', 'woocommerce' );
}
}
If you need further assistance please let us know.
Best regards,
Victoria