I need to change the default “Add To Cart” button text to ”Buy now“. I solved it by adding such a function to the function.php file of the child theme:
add_filter('woocommerce_product_add_to_cart_text', 'replace_cart_text');
add_filter('woocommerce_product_single_add_to_cart_text', 'replace_cart_text');
function replace_cart_text()
{
return 'Buy now';
}
The problem is that I use different languages on the site. How to modify function to display different text on the buttons for each language? My translation plugin is Polylang.
2
Answers
I solved this problem by adding condition to the function:
You can try with the plugin references in the below link for a better translation for woocommerce.
https://www.cloudways.com/blog/woocommerce-multilingual/