NO BUG: {woo_product_excerpt} Shows Full Product Description when short description is empty

When using the {woo_product_excerpt} dynamic tag, if a product does not have a short description set, the tag falls back to displaying the full product description. This results in unintended long content being shown where only a short summary is expected.

Steps to Reproduce:

  1. Create or edit a WooCommerce product.
  2. Leave the “Short Description” field empty.
  3. Add {woo_product_excerpt} to a template or product display.
  4. View the product on the front end.

Expected Behaviour:
If the short description is empty, {woo_product_excerpt} should return blank (or nothing) instead of pulling in the full product description.

Actual Behaviour:
If the short description is empty, {woo_product_excerpt} displays the entire product description, leading to layout and content duplication issues.

Hi @Corsto,

I’ll mark this one as a no bug, because this is how WooCommerce works. If there is no excerpt, it will take a content, and in the case of the product, this will be full description. Now, by default I think it’s also limited to 55 words, but you can use it like this: {woo_product_excerpt:20} and it will limit it to 20 words max.

I suppose this should help.
Matej

Is it possible to display the short description only and if it is empty then return nothing?

Hi @Andris,

There is no built-in modifier for {woo_product_excerpt} that disables the WooCommerce/WordPress excerpt fallback. The current tag follows the normal excerpt behavior: if the product short description is empty, the excerpt is generated from the product content.

For short-description-only output, use a custom function and call it via an Echo Function dynamic tag. (Not tested, but it should work):

function bricks_product_short_description_only() {
	$post_id = get_the_ID();

	if ( get_post_type( $post_id ) !== 'product' ) {
		return '';
	}

	$excerpt = get_post_field( 'post_excerpt', $post_id );

	return $excerpt !== '' ? apply_filters( 'woocommerce_short_description', $excerpt ) : '';
}

add_filter( 'bricks/code/echo_function_names', function( $functions ) {
	$functions[] = 'bricks_product_short_description_only';
	return $functions;
} );

Then use this dynamic tag where needed:

{echo:bricks_product_short_description_only}

Echo functions need to be explicitly allowed, as documented here: Filter: bricks/code/echo_function_names | Bricks Academy

Best regards,
Matej

Hello Matej,

I did a similar solution. Thank you for your kind help!

András

Nice, I’m glad that you got it working. :slight_smile: Thanks for letting us/me know :victory_hand:

Matej