Edits the Add To Cart text on Single Product Page

How do you customize the default “Add to cart” text on single product page? You can easily do it without editing the core file.

There have a filter “woocommerce_product_single_add_to_cart_text” for single product’s add to cart text.

Change The Add to cart Text

add_action( 'woocommerce_product_single_add_to_cart_text', 'paulc_change_single_add_to_cart_text' );
function paulc_change_single_add_to_cart_text( $text ) {
	$new_text =__('Add to basket', 'woocommerce' );
    
    return $new_text;
}

Adds Price Value in Add to cart Button

add_action( 'woocommerce_product_single_add_to_cart_text', 'paulc_change_single_add_to_cart_text', 10, 2 );
function paulc_change_single_add_to_cart_text( $text, $product ) {
	$price = get_woocommerce_currency_symbol( get_woocommerce_currency() ) . wc_get_price_to_display( $product );
	$new_text = $text . __(' for ', 'woocommerce' ) . $price;
    return $new_text;
}

Where are you add the PHP snippet?
You will add the PHP snippet in your theme’s functions.php file or your custom plugin’s PHP file.

This site uses cookies to offer you a better browsing experience. By browsing this website, you agree to our use of cookies.