Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

woocommerce_after_add_to_cart_button

Fires right after the Add to cart button on single product pages, still inside the form. Use it for links or short notes.

  • Type Action
  • From WooCommerce
  • Since 1.2.1
  • Fired in templates/single-product/add-to-cart/simple.php

When it fires

WooCommerce fires this action straight after the Add to cart button, before the closing tag, on single product pages. It's in the add to cart templates for simple, variable, grouped and external products.

The global $product is available, so you can check the product's type, category or stock before printing anything.

Parameters

None. Your callback takes no arguments.

Example: Add a size guide link for clothing

PHP
add_action( 'woocommerce_after_add_to_cart_button', function () {
	global $product;
	if ( ! $product instanceof WC_Product || ! has_term( 'clothing', 'product_cat', $product->get_id() ) ) {
		return;
	}
	printf(
		'<a class="size-guide-link" href="%1$s">%2$s</a>',
		esc_url( home_url( '/size-guide/' ) ),
		esc_html__( 'Size guide', 'my-snippets' )
	);
} );

Good to know

  • Block themes: the Add to Cart + Options block fires this hook as well.
  • To add something below the whole form instead, use woocommerce_after_add_to_cart_form.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.