How To Change WooCommerce Add To Cart Button Text
Unfortunately, changing WooCommerce “Add To Cart” -button text can’t be easily changed through the customization option. Thankfully it can be changed relatively easily with a piece of code we will show you.
How to change the add-to-cart text in the WooCommerce shop archive
To change the “Add To Cart” -buttons text on the shop archive page you need to add the following code to your functions.php file.
// 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' );
}
Below you can see the default “Add to cart“…
…and after adding the code we can see the new “BUY NOW” instead of the default text.
How to change the add-to-cart text in WooCommerce single product page
If you wish to change the “Add To Cart” text on your single product page you will need to include this code in your functions.php as well:
// 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' );
}
Below you can see the default “Add to cart“…
… and after adding the code we have a new “Buy now” text.
Conclusion
In conclusion, editing the “Add To Cart” -button text is fairly simple with just a few lines of code. If you wish to edit the “Add To Cart” -text in the WooCommerce shop archive and in the single product page, simply add both codes to your themes funtions.php file.
// 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' );
}
// 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' );
}
Note – Remember to add the codes to your child themes function.php or they will be removed when you update your main theme.