Следующий код изменит текст кнопки «Добавить в корзину» в зависимости от определенных идентификаторов продукта:
add_filter( 'woocommerce_product_add_to_cart_text', 'custom_loop_add_to_cart_button', 20, 2 );
function custom_loop_add_to_cart_button( $button_text, $product ) {
// HERE define your specific product IDs in this array
$specific_ids = array(37, 40, 53);
if( in_array($product->get_id(), $specific_ids) ) {
$button_text = __("add to cart", "woocommerce");
} else {
$button_text = __('+', 'woocommerce');
}
return $button_text;
}
Код помещается в файл function.php вашей активной дочерней темы (или активной темы). Проверено и работает.