Search the site:

Home Blog How to add text below the short description of the Product in WooCommerce

How to add text below the short description of the Product in WooCommerce

WooCommerce lets us write a short description for every product that we add to our store, which appears alongside the product image as illustrated in the image below:

How to add text below the short description of the Product in WooCommerce - Default Short Description

 

This “short description” can be updated anytime that you wish to add some text to it.

However, sometimes, it may so happen that you want to have a site-wide or a store-wide sale, or display an important notification such as that of exclusion of taxes in the price, shipping costs, free shipping above a certain price or of stocks selling fast. In all these cases, it is not feasible to add text to the short description field of every product. In this post, you will learn how to add text below the short description of the product in WooCommerce through code snippets, such that this text gets added to all products in the store.

Add the code snippet below to the functions.php file of your child theme, and assign any text that you wish to display to the variable $text :

add_filter('woocommerce_short_description','ts_add_text_short_descr');
function ts_add_text_short_descr($description){
  $text="Offer: 40% OFF at Checkout on all products across the store.";
  return $description.$text;
}

(To know why we edit the functions.php of the child theme and not directly the functions.php file, read this post.)

Here, woocommerce_short_description is a Woocommerce filter associated with the short description of a product to which we are adding a hook/function called as “ts_add_text_short_descr”. The function returns the short description of the product along with the added text. This added text is added to the short description of every product in the store:

How to add text below the short description of the Product in WooCommerce - Added text to short description example1

How to add text below the short description of the Product in WooCommerce - Added text to short description example2

 

You can even add HTML tags to the text to format it. For example,

add_filter('woocommerce_short_description','ts_add_text_short_descr');
function ts_add_text_short_descr($description){
  $text="<b>Offer:</b> 40% OFF at Checkout on all products across the store.<br/><br/>";
  return $description.$text;
}

Modifying the earlier code snippet to the one above will format the added text according to the HTML tags mentioned in the string assigned to the variable $text.

How to add text below the short description of the Product in WooCommerce - Formatted the added short description text.

In this way, you can add any text below the short description of products in WooCommerce.

Adding content (be it HTML, text or images) above the short description can also be done using code snippets, in various ways as shown in this post.

Leave a Reply

avatar

This site uses Akismet to reduce spam. Learn how your comment data is processed.

  Subscribe  
Notify of
from purchased

Subscribe Now