I have found the following code from this answer thread, but it only applied under the product title. So how can apply to the detailed description of the product.
add_action( 'woocommerce_after_shop_loop_item_title', 'shorten_product_excerpt', 35 );
function shorten_product_excerpt()
{
global $post;
$limit = 14;
$text = $post->post_excerpt;
if (str_word_count($text, 0) > $limit) {
$arr = str_word_count($text, 2);
$pos = array_keys($arr);
$text = substr($text, 0, $pos[$limit]) . '...';
// $text = force_balance_tags($text); // may be you dont need this…
}
echo '<span class="excerpt"><p>' . $text . '</p></span>';
}
In Woocommerce product single pages, the long description is displayed in the "description tab". If you look at the source code of
single-product/tabs/description.php
template, it usethe_content()
wordpress function to display that long description.So you can use
the_content
dedicated Wordpress filter hook to reduce the product long description:Code goes in function.php file of your active child theme (or active theme). Tested and works.
Before:
After:
Similar: Limit product short description length in Woocommerce