I\'m running WooCommerce version 2.5.5. The following lines of code don\'t seem to change the Add To Cart button text on my product page for an item with variations:
<Update: for WooCommerce 3+
You are using an obsolete hook for prior versions 2.1 of WooCommerce (see at the bottom the reference).
First you can target the desired product type in those (new) hooks with conditions:
global $product;
if ( $product->is_type( 'simple' ) ) // for simple product
// Your text for simple product
if ($product->is_type( 'variable' ) ) // for variable product
// Your text for variable product
if ($product->is_type( 'grouped' ) ) // for grouped product
// Your text for grouped product
if ($product->is_type( 'external' ) ) // for external product
// Your text for external product
Now you have 2 available hooks for Woocommerce:
add_filter( 'woocommerce_product_single_add_to_cart_text', 'my_custom_cart_button_text', 10, 2 );
add_filter( 'woocommerce_product_add_to_cart_text', 'my_custom_cart_button_text', 10, 2 );
And you will use one or both of them with your customized function targeting through the variables product type condition, this way:
function my_custom_cart_button_text( $button_text, $product ) {
if ( $product->is_type( 'variable' ) )
$button_text = __('Buy Now', 'woocommerce');
return $button_text
}
You can also have a custom button text by product type: See here.
Reference: Change add to cart button text
The correct filter for the single product page is woocommerce_product_single_add_to_cart_text.
function my_custom_cart_button_text( $text, $product ) {
if( $product->is_type( 'variable' ) ){
$text = __('Buy Now', 'woocommerce');
}
return $text;
}
add_filter( 'woocommerce_product_single_add_to_cart_text', 'my_custom_cart_button_text', 10, 2 );