Show WooCommerce “Added to Cart” Message on Single Product Page

Quick Summary

  • Call do_action() for woocommerce_before_single_product near the top of a custom single product template to restore the added-to-cart notice.
  • That hook also runs woocommerce_output_all_notices(), so error messages and other notices appear in the same spot.
  • Notices clear once printed, and with Redirect to the cart page enabled, customers see the message on the cart instead.

After a customer adds a product to the cart from a single product page, WooCommerce shows its added to cart message, with a View cart button. If you use a custom single product template, that notice can go missing, because WooCommerce prints it through an action hook your template no longer calls.

To bring it back, add this line where you want the message to appear, usually at the top of the template, before the product markup:

PHP
<?php do_action( 'woocommerce_before_single_product' ); ?>

How it works

WooCommerce attaches its notice output function, woocommerce_output_all_notices(), to the woocommerce_before_single_product action. Calling do_action() runs it, along with anything else plugins attach to that hook, so the added-to-cart message, error messages and other notices all show up.

  • If Redirect to the cart page after successful addition is enabled under WooCommerce > Settings > Products, customers go to the cart instead, and the message appears there.
  • WooCommerce clears notices once it prints them. If another part of the page prints them first, this spot stays empty.

For notices and add-to-cart feedback designed into your product pages, see my WooCommerce development services.

Share on X (opens in a new tab) Share on LinkedIn (opens in a new tab) Share on Facebook (opens in a new tab)

ChatGPT (opens in a new tab) Claude (opens in a new tab) Gemini (opens in a new tab) Perplexity (opens in a new tab) Grok (opens in a new tab)

More Insights

See More