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

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

by Tutor Aspire

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 tutoraspire.com FREE
 * @author        Tutor Aspire
 * @compatible    WooCommerce 6
 * @donate $9     https://tutoraspire.com
 */

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

function tutoraspire_echo_short_desc_if_empty() {
   global $post;
   if ( empty ( $post->post_excerpt  ) ) {
      $global_excerpt = '

'; $global_excerpt .= 'This is the default, global, short description.
It will show if no short description has been entered!'; $global_excerpt .= '

'; echo $global_excerpt; } }

You may also like