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.
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.';
}
This code will display a custom message right before the add to cart button in the product description as shown in the image below.