Black Friday & Cyber Monday SUPER SALE ALL WEEK:
Grab 40% OFF on plugins
Days
Hours
Minutes
Seconds

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.

Browse more in: Code Snippets, WooCommerce How Tos, WooCommerce Tutorials

Share It:

Subscribe
Notify of
16 Comments
Newest
Oldest
Inline Feedbacks
View all comments
John Doe
9 months ago

i have a new problem hehe
the problem occurs in the product variable

additional text show 2 times. like in the picture I attached

maybe you can help. thanks 🙂

image (9).png
yudi
9 months ago

how if I want to put the text before the description

yudi
9 months ago
Reply to  Anubha Bhat

I put this code in functions.php on the child theme ?

thanks before 🙂

10 months ago

Can I html instead plain text in this snippet? Thanks

bruno
2 years ago

Hi Thanks how can I change the color of the text I added only?

darren
1 year ago
Reply to  bruno

if using paragraph text use <p style=’color:red;’>your text</p> or add a class to the text with <p class=’your-class’>your text</p> then style the class.

Jeff
3 years ago

Would there be a way to do this, but also to apply it only to certain categories or products? Ex: I want a disclaimer text I want to appear on all products under my “exclusive” category. Based on the snippet in the original article, is there a way to modify it to show only on products under that “exclusive” category?

16
0
Would love your thoughts, please comment.x
()
x