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:
add_filter('variable_add_to_cart_text', 'my_custom_cart_button_text');
function my_custom_cart_button_text() {
return __('Buy Now', 'woocommerce');
}
Would you happen to know what I’m missing?
The correct filter for the single product page is
woocommerce_product_single_add_to_cart_text
.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:
Now you have 2 available hooks for Woocommerce:
And you will use one or both of them with your customized function targeting through the variables product type condition, this way:
You can also have a custom button text by product type: See here.
Reference: Change add to cart button text