Changing Woocommerce Product Description

The question:

I’ve been changing the way that the Single product page looks. I’ve moved a few things about by hooking into Woocommerce and also editing the css.

Out of the box the single product page shows the short description (described as woocommerce_template_single_excerpt in the content-single-product.php file) next to the product image, but I want to show the full description.

The full description is shown in the product data tabs underneath the product. Looking in the tabs directory at the description.php file it seems to just set the heading. Presumably as the product is a custom post type the product description is the content of the custom post.

I’ve worked around it by putting the full description in the product short description section but I’d like a solution that doesn’t require someone adding products to have to do this.

Can anyone suggest a way of doing this please?

The Solutions:

Below are the methods you can try. The first solution is probably the best. Try others if the first one doesn’t work. Senior developers aren’t just copying/pasting – they read the methods carefully & apply them wisely to each case.

Method 1

Instead of editing the template you could also try this:

<?php

/** Remove short description if product tabs are not displayed */
function dot_reorder_product_page() {
    if ( get_option('woocommerce_product_tabs') == false ) {
        remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_excerpt', 20 );
    }
}
add_action( 'woocommerce_before_main_content', 'dot_reorder_product_page' );

/** Display product description the_content */
function dot_do_product_desc() {

    global $woocommerce, $post;

    if ( $post->post_content ) : ?>
        <div itemprop="description" class="item-description">
            <?php $heading = apply_filters('woocommerce_product_description_heading', __('Product Description', 'woocommerce')); ?>

            <!-- <h2><?php echo $heading; ?></h2> -->
            <?php the_content(); ?>

        </div>
    <?php endif;
}
add_action( 'woocommerce_single_product_summary', 'dot_do_product_desc', 20 );

Method 2

Slightly different fix provided by Woocommerce so I thought I should include it here:

In templates/single-product/short-description.php where it says:

    $post->post_excerpt 

Replace this (2 occurrences) with;

    $post->post_content 

Thanks

Method 3

I never understood this either from woocommerce… I’d expect a ‘product description’ as the main post info and then perhaps ‘detailed description’ or ‘additional product information’ in the tab.

in templates/single-product/short-description.php replace

if ( ! $post->post_excerpt ) return;
?>
<div itemprop="description">
    <?php echo apply_filters( 'woocommerce_short_description', $post->post_excerpt ) ?>

with

if ( ! the_content() ) return;
?>
<div itemprop="description">
    <?php echo the_content(); ?>

then in templates/single-product/tabs/description.php replace

<?php the_content(); ?>

with

<?php the_excerpt(); ?>

Method 4

Use woocommerce template in price.php

add_action( 'woocommerce_after_shop_loop_item_title', 'my_add_short_description', 9 );
function my_add_short_description() {
      echo '<span class="title-description">' . the_excerpt() . '</span><br />';
} 


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Comment