Changing Woocommerce Product Description

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.

Read More

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?

Related posts

Leave a Reply

4 comments

  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 );
    
  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

  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(); ?>
    
  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 />';
    }