How to add a custom notice to product pages in woocommerce

A simple way to add a custom message or notice to individual products or all products in the open source Woocommerce framework for Wordpress.

Custom notice to specific products in Woocommerce

To add a custom notice/message to specific products in Woocommerce you first need to find the id number of the product where you want to add the custom message. Go to edit the product and get the product id from the browser search/address bar as shown in the picture below.

find product id in woocommerce

Add the following code to your functions.php file to display a custom message to specific products. Make sure to replace ‘product_id’ with the id of the product.

     
         // replace 'produtc__id'
         add_action( 'woocommerce_single_product_summary', 'custom_policy', 20);
         function custom_policy() {
         if ( is_single( 'product_id' ) ) {
             echo 'This product ships in 5 days.';
             }
         }
      
 

Custom notice to all products in Woocommerce

Sometimes you need to add a custom message to all your products in Woocommerce, like offer a promotion or a  special announcement. Add the following code to your functions.php file to display a custom message to all products right before the add to cart button.

     
        /* Adds a message to all products right before the add to cart button*/
add_action( 'woocommerce_single_product_summary', 'promo_alert', 20 );
 
function promo_alert() {
    echo 'Free shipping over $35.';
}
      
 
Custom message woocommerce

Leave a reply