Reputation: 57
I am trying to change the Add To Cart text on the product page button to Buy Now I've tried using the function that's being posted everywhere to solve the issue but somehow that doesn't seem to do the trick, also using a WordPress plugin is not changing the text.
So far I've found the following function
// To change add to cart text on single product page
add_filter( 'woocommerce_product_single_add_to_cart_text', 'woocommerce_custom_single_add_to_cart_text' );
function woocommerce_custom_single_add_to_cart_text() {
return __( 'Buy Now', 'woocommerce' );
}
// To change add to cart text on product archives(Collection) page
add_filter( 'woocommerce_product_add_to_cart_text', 'woocommerce_custom_product_add_to_cart_text' );
function woocommerce_custom_product_add_to_cart_text() {
return __( 'Buy Now', 'woocommerce' );
}
Adding that to my Code Inserter creates an error and breaks the website.
I think that Divi is overruling the function from somewhere. Any tips or ideas?
Upvotes: 0
Views: 373
Reputation: 5
I used the plugin snippets which normally always works for this kind of stuff but it doesn't. CBroe above gave the right answer, saying putting it in functions.php gives it a different priority, which made it work.
I am just highlighting it and confirming it again as the solution as it was very hard to find this post.
So changing the divi add to cart button tekst can be done in this way. Putting the code in a child theme also prevents it from being removed when updating your wordpress website. That was one of the reasons I used snippets....
Upvotes: 0