How to change woocommerce add to cart text by custom code?

To change the “Add to Cart” text on a single product page in WooCommerce, you can use the following code snippet in your theme’s functions.php file or in a custom plugin:

add_filter( 'woocommerce_product_single_add_to_cart_text', 'woo_custom_cart_button_text' );   
function woo_custom_cart_button_text() {
    return __( 'My Custom Text', 'woocommerce' );
}

This code uses the ‘woocommerce_product_single_add_to_cart_text’ filter to change the text of the “Add to Cart” button on the single product page to “My Custom Text”. You can replace “My Custom Text” with your own desired text. Please make sure to take a backup of your functions.php file before making any changes.

Leave a Reply