I am changing the text of the Add to cart button on shop pages in WooCommerce for specific products:
add_filter( 'woocommerce_product_add_to_cart_text', 'add_to_cart_text' );
function add_to_cart_text( $default ) {
if ( get_the_ID() == 1 ) {
return __( 'Text1', 'your-slug' );
} elseif ( get_the_ID() == 2 ) {
return __( 'Text2', 'your-slug' );
} elseif ( get_the_ID() == 3) {
return __( 'Text3', 'your-slug' );
} else {
return $default;
}
}
If I have two or more IDs that need to have the same button text, how can I add an array of these ids into my function?
