WooCommerce: Display Global Short Description When Empty @ Single Product Page

The WooCommerce product short description is that piece of content that appears on the right hand side of the featured image above the add to cart button. This is, of course, unless you forgot to enter the short description under Product > Edit Product > Short Description!

In case you forgot to enter it or you want to display a global short description, here’s a quick PHP snippet for you. Enjoy!

WooCommerce: display a custom short description when empty @ single product page

PHP Snippet: Display Custom Short Description When Empty @ WooCommerce Single Product Page

/**
 * @snippet       Show Global Short Description If Empty - WooCommerce
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 6
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

add_action( 'woocommerce_single_product_summary', 'bbloomer_echo_short_desc_if_empty', 21 );

function bbloomer_echo_short_desc_if_empty() {
   global $post;
   if ( empty ( $post->post_excerpt  ) ) {
      $global_excerpt = '<p class="default-short-desc">';
      $global_excerpt .= 'This is the default, global, short description.<br>It will show if <b>no short description has been entered!</b>';
      $global_excerpt .= '</p>';
      echo $global_excerpt;
   }
}

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (delete "?>" if you have it there). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7.3.

If you think this code saved you time & money, feel free to join 14,000+ WooCommerce Weekly subscribers for blog post updates or 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

16 thoughts on “WooCommerce: Display Global Short Description When Empty @ Single Product Page

  1. Is it possible to add a shortcode in place of ‘This is the default, global, short description.It will show if no short description has been entered!‘; ? I would like to add the shortcode [specs-table]. Thanks in advance

    1. Sure, check the WordPress function do_shortcode()

  2. Show can i show the product description instead of the custom text?

  3. How can we do this but for the product description itself not the product short description ?

    1. Hi Maged, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  4. Thank you for your post. How can I add the “Short Description” by specific tags? Or insert the main descriptions to the short descriptions?

    1. Hi Steve, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. When we force the short description it is not picked up by the woocommerce schema any ideas how we can all fix this? Schema has become a big thing lately with Google. ๐Ÿ™‚

    1. Hello Nexus, thanks so much for your comment! Yes, this is possible – unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  6. Hi,

    This snippet works great for Single posts where it displays only once, however for variable products when a variation is selected it displays twice.

    I can hide the second custom short description by using css, but was wondering if there is a way to hide is programmatically.

    Thanks

    1. You’re right – snippet updated!

  7. That’s a really good idea. Something to enhance it just a little more would be to pull a short description from an associated tag or category, therefore if there is nothing in the product description for that item, it can pull a generic one for whatever is in that category, whether it be “boys shorts”, “men’s watches”, “pizzas”, “flooring”, etc.

    1. Nice idea! Thank you Madivad ๐Ÿ™‚

  8. Another amazing snippet!

    1. Thank you ๐Ÿ™‚

Questions? Feedback? Support? Leave your Comment Now!
_____

If you are writing code, please wrap it between shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

Your email address will not be published. Required fields are marked *