Add Text Before and After Add to Cart

On Single Product Pages

Text after Add to Cart button on single product pages WooCommerce
On the screenshot I also added some CSS to the message.

Before Add to Cart Button

Can be done easily with woocommerce_before_add_to_cart_button hook, example:

add_action( 'woocommerce_before_add_to_cart_button', 'misha_before_add_to_cart_btn' );

function misha_before_add_to_cart_btn(){
	echo 'Some custom text here';

If you are going to use some conditions there, you can obtain current product ID with get_the_ID() function.

After Add to Cart Button

If you are going to add some custom text after “Add to Cart” button, woocommerce_after_add_to_cart_button hook should help you. Example of usage this hook

add_action( 'woocommerce_after_add_to_cart_button', 'misha_after_add_to_cart_btn' );

function misha_after_add_to_cart_btn(){
	echo 'Some custom text here';

2 More Hooks

But there also 2 more hooks which are very similar – woocommerce_before_add_to_cart_form and woocommerce_after_add_to_cart_form.

I think you can even guess what is their difference. So, the hook woocommerce_before_add_to_cart_form will be fired a little bit earlier that woocommerce_before_add_to_cart_button, before <form> tag.

And the hook woocommerce_after_add_to_cart_form will be fired a little bit later than woocommerce_after_add_to_cart_button, after the closing </form> tag.

On Shop / Product Category Pages

Do you think the above hook will work the same in case you want to add some text on the archive pages? Nope 😁 It is completely different here. But also simple.

Text after Add to Cart button on shop and archive pages.
Works perfectly for Variable products too

Either you would like to display the text before the Add to Cart button or after – in both cases woocommerce_loop_add_to_cart_link should be OK for you.

Just look at this example and everything will become clear for you:

add_filter( 'woocommerce_loop_add_to_cart_link', 'misha_before_after_btn', 10, 3 );

function misha_before_after_btn( $add_to_cart_html, $product, $args ){
	$before = ''; // Some text or HTML here
	$after = ''; // Add some text or HTML here as well

	return $before . $add_to_cart_html . $after;
It is a product object – it could be WC_Product_Simple or WC_Product_Variable or even WC_Product_Subscription if you are using WooCommerce Subscriptions plugin. You can obtain $product->id from these objects for example.
It just contains button attributes like quantity, class names etc

More WooCommerce

Misha Rudrastyh

Misha Rudrastyh

I develop websites since 2008, so it is total of 14 years of experience, oh my gosh. Most of all I love love love to create websites with WordPress and Gutenberg, some ideas and thoughts I share throughout my blog.

Need some developer help? Contact me

Follow me on Twitter