Customizing Woocommerce Product Description Title

My wife and I have been developing a WordPress site running Woocommerce as a registration and payment portal for a charity golf tournament. Upon showing our client the site, they requested that the words “Product Description” be changed to reflect the title of the item. Since this option doesn’t exist in Woocommerce, I had to do some customizing. Here’s how the default Woocommerce Product Description page looks:

casa1

Woocommerce creates this page using this file:

./wp-content/plugins/woocommerce/templates/single-product/tabs/description.php

Here’s the code:

<?php
 /**
  * Description tab
  *
  * @author         WooThemes
  * @package     WooCommerce/Templates
  * @version     2.0.0
  */
if ( ! defined( 'ABSPATH' ) 
) {
     exit; // Exit if accessed directly
 }
global $post;
 $heading = esc_html( apply_filters( 'woocommerce_product_description_heading'
  , __( 'Product Description', 'woocommerce' ) ) );
 ?>
<?php if ( $heading ): ?>
   <h2><?php echo $heading; ?></h2>
 <?php endif; ?>
<?php the_content(); ?>

Woocommerce uses a few functions to query the database and return the data for the page and inputs them to variable $heading. Upon output, it outputs the words “Product Description” in h2 tags. To change this, we need to replace $heading with the function the_title():

<?php
 /**
  * Description tab
  *
  * @author         WooThemes
  * @package     WooCommerce/Templates
  * @version     2.0.0
  */
if ( ! defined( 'ABSPATH' ) ) {
     exit; // Exit if accessed directly
 }
 global $post;
//$heading = esc_html( apply_filters( 'woocommerce_product_description_heading'
  , __( 'Product Description', 'woocommerce' ) ) );
echo '<h2>';
 the_title();
 echo '</h2>';
the_content();
 ?>

 

Commenting out the $heading declaration and replacing echo of $heading with the_title() function returns the title of the product in the h2 tags instead of the generic “Product Description”:

 

casa2

 

Alternatively, you can replace it with anything else, like “Item Description” by replacing the function call, the_title() with: echo ‘Item Description’;

This is one of the fun ways you can bend Woocommerce. Remember to keep a backup of this file locally, since it maybe replaced upon updating the Woocommerce plugin.

Leave a Reply

Your email address will not be published. Required fields are marked *