[SOLVED] How To Change WooCommerce Button Text

[SOLVED]How To Change WooCommerce Button Text

How To Change “Add to Cart” to “Buy Now” WooCommerce Button Text

 

Hello! Today I will teach you how to change the WooCommerceAdd to Cart” button text to “Buy Now” or whatever you want to. For this, you have at least two options:

BEFORE ANYTHING, DO A FULL BACKUP OF YOUR SITE. RIGHT NOW! 

OK, so assuming you did a full backup of your site, in order to change the “Add to Cart” button text to “Buy Now / Order / Hire Me / and so on”, you must add the following PHP code into your theme:

// Change the Add To Cart Button Text on the 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' ); 
}

// Change the Add To Cart Button Text on the 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' );
}

Option 1: Changing the WooCommerce Button Text From The Main Theme:

WP-Dashboard -> Appearance -> Main Theme (the active one) -> Theme editor -> (locate the functions.php file) -> Add the PHP code from above at the bottom of the functions.php page -> Save the file.

If the change doesn’t seems to appear, try to clean your browser cache.


Option 2: Changing the WooCommerce Add to Cart Button Text From The Child Theme (SAFEST METHOD):

This is the safest method, because anytime you’ll update the theme your are using on your WordPress site, the configurations you applied on your site will still be there. If you apply tweaks on the main theme, once you’ll update it, you may lose those tweaks.

Assuming you have the Child Theme activated, go to: WP-Dashboard -> Appearance -> Child Theme (the active one) -> Theme editor -> Functions.php (in fact, I think this is the only file you should see on the child theme) -> Add the PHP code.


Cannot Find The Child Theme Editor In The Dashboard

If you cannot locate the functions.php from the admin dashboard, you can try the following thing:

Go to cPanel -> File Manager -> Public HTML (or the folder where your WordPress Site’ s files are stored) -> WP Content -> Themes -> Theme_Folder (best is to go to Child_Theme_Folder) -> You should see the functions.php there. Open with an editor, paste the code above and save it.

Related Posts

Menu