Title: Display custom message
Last modified: January 20, 2021

---

# Display custom message

 *  [danie1234](https://wordpress.org/support/users/danie1234/)
 * (@danie1234)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/display-custom-message/)
 * Hi. I would like to display a custom message when a product is not purchable,
   for example on the location where the cart button would be. Instead of only hiding
   the cart button. Is that possible?

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Plugin Author [WPClever](https://wordpress.org/support/users/wpclever/)
 * (@wpclever)
 * [5 years, 4 months ago](https://wordpress.org/support/topic/display-custom-message/#post-13935997)
 * Hi [@danie1234](https://wordpress.org/support/users/danie1234/)
 * When a product is un-purchasable, WooCommerce will hide the add to cart form 
   by default.
 * You can display your message by adding the below code to current-theme (or child-
   theme) / functions.php
 *     ```
       add_action( 'woocommerce_single_product_summary', 'woopt_single_product_summary', 25 );
       function woopt_single_product_summary() {
       	global $product;
   
       	if ( ! $product->is_purchasable() ) {
       		echo '<span style="color: red">Your message here!</span>';
       	}
       }
       ```
   
 * And the result [https://www.screencast.com/t/38lxgZFbRMV](https://www.screencast.com/t/38lxgZFbRMV)
 *  [espermedia](https://wordpress.org/support/users/espermedia/)
 * (@espermedia)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/display-custom-message/#post-14175270)
 * This is not working for me in Astra theme… Button is removed, but no message 
   is displayed on its place.
 *  [espermedia](https://wordpress.org/support/users/espermedia/)
 * (@espermedia)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/display-custom-message/#post-14175275)
 * The button wrapper section remains on the screen, but is empty – nothing is output
   by this function.
    -  This reply was modified 5 years, 3 months ago by [espermedia](https://wordpress.org/support/users/espermedia/).

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Display custom message’ is closed to new replies.

 * ![](https://ps.w.org/woo-product-timer/assets/icon-128x128.png?rev=1858857)
 * [WPC Product Timer for WooCommerce](https://wordpress.org/plugins/woo-product-timer/)
 * [Support Threads](https://wordpress.org/support/plugin/woo-product-timer/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-product-timer/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-product-timer/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-product-timer/reviews/)

 * 3 replies
 * 3 participants
 * Last reply from: [espermedia](https://wordpress.org/support/users/espermedia/)
 * Last activity: [5 years, 3 months ago](https://wordpress.org/support/topic/display-custom-message/#post-14175275)
 * Status: not resolved