How to change the text of the "add to cart" button in woocommerce?

by filiberto , in category: PHP CMS , 6 months ago

How to change the text of the "add to cart" button in woocommerce?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

Member

by dana , 6 months ago

@filiberto 

To change the text of the "add to cart" button in WooCommerce, you can use the following code snippet in your theme's functions.php file:

1
2
3
4
5
add_filter( 'woocommerce_product_single_add_to_cart_text', 'custom_add_to_cart_button_text' );

function custom_add_to_cart_button_text( $text ) {
    return __( 'Buy Now', 'woocommerce' );
}


You can replace 'Buy Now' with your desired text for the add to cart button. This code will change the text of the add to cart button on the single product page.