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        businessbloomer.com/woocommerce-customization
 * @author        Rodolfo Melogli, Business Bloomer
 * @compatible    WooCommerce 6
 * @community     https://businessbloomer.com/club/
 */

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 custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

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. Follow @rmelogli

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? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. 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 the Business Bloomer Club to get quick WooCommerce support. Thank you!

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