---
description: >-
  https://www.cloudways.com/blog/display-product-description-in-product-pages-on-woocommerce/
---

# How to Display Product Description in WooCommerce Store (ok)

C:\xampp\htdocs\jp1\wp-content\themes\muum-child\functions.php

```
function cloudways_short_des_product() {
  the_excerpt();
}
add_action( 'woocommerce_after_shop_loop_item_title', 'cloudways_short_des_product', 40 );
```

## How to Display Product Description in WooCommerce Store

![](https://secure.gravatar.com/avatar/55fb92ae9ea7eca129678ce04ff52ac7?s=128\&d=mm\&r=g) [Owais Alam](https://www.cloudways.com/blog/author/owaisalam/) &#x20;

June 29, 2019  4 Min Read![How to Display Product Description in WooCommerce](https://www.cloudways.com/blog/wp-content/uploads/How-To-Display-Product-Description-in-WooCommerce-Banner.jpg)

WooCommerce comes packaged with archive pages and loops that make the WooCommerce [product description](https://www.cloudways.com/blog/product-description-examples/) display awesome. Yet here and there you may need to show more data on your main shop and other archive pages. This tutorial demonstrates how to show a WooCommerce short description of products to archive pages and display it below the title of the product. You can also [add a minimum shipping requirement rule on products.](https://www.cloudways.com/blog/add-minimum-shipping-requirements-rule-on-products-in-woocommerce/)

#### **Create WooCommerce Product Description Plugin**

In your **wp-content/plugins** directory, create a PHP file with the name cloudways-product-shor-des.php

Open the file in your code editorial manager. At the top of the file, including this:

1. \<?php
2. /\*
3. &#x20;\* Plugin Name: Cloudways Display WooCommerce Product Short Description
4. &#x20;\* Description: Add WooCommerce product short description to the loop in product archive pages
5. &#x20;\* Version: 1.0
6. &#x20;\*/

This sets up the plugin and gives WordPress all that it needs to activate it.

Now go to the **Plugins** area in the WordPress admin area and find the plugin:

![wordpress plugin setting](https://www.cloudways.com/blog/wp-content/uploads/plugin-screen.jpg)

Now Activate the WooCommerce product description plugin.

At first, it won’t have any effect as you haven’t populated it. This is what the shop page looks like right at this point:

![woocommerce shop page before](https://www.cloudways.com/blog/wp-content/uploads/shop-page-before.jpg)

### Function to get short description WooCommerce

The short description for products in WooCommerce utilizes the excerpt that you’d find in normal posts. So to show it, you should simply show the excerpt for the post.

In your plugin file, add the code to get product description WooCommerce:

1. &#x20;function cloudways\_short\_des\_product() {
2.
3. &#x20;the\_excerpt();
4. }

It’s as basic as that! Yet, now you have to hook your function to the right activity so that it’s output in the correct place in your archive pages.

#### Cloudways Woocommerce Hosting Has No Restrictions!

Test your code, plugins and themes with ease.[GET STARTED FREE](https://platform.cloudways.com/signup?utm_source=WooBlogs\&utm_medium=InlineCTA\&utm_campaign=WooConvImprovement)

#### **Function Hook for Correct Action to add WooCommerce short description**

How about we investigate the file in WooCommerce that output the content of the loop on archive pages? This file is **content-product.php**, and you’ll see it in the **templates** folder in the WooCommerce plugin by using the WooCommerce product description hook. The file incorporates various action hooks, all of which are utilized by WooCommerce to output different content.

As we need to show our excerpt below the title of the product, the hook we have to utilize is **woocommerce\_after\_shop\_loop\_item\_title** . As you can see from the **content-product.php** file, it’s now got two functions attached to it, **woocommerce\_template\_loop\_rating()** and **woocommerce\_template\_loop\_price()**, which have priorities of 5 and 10 separately. So we need to hook our function with a higher priority number, to ensure it fires after those. I’ll leave some leeway and use 40 as the priority.

Beneath your function, add this:

1. add\_action( 'woocommerce\_after\_shop\_loop\_item\_title', 'cloudways\_short\_des\_product', 40 );

Now the complete WooCommerce description code becomes:

1. function cloudways\_short\_des\_product() {
2. &#x20;the\_excerpt();
3. }
4.
5. add\_action( 'woocommerce\_after\_shop\_loop\_item\_title', 'cloudways\_short\_des\_product', 40 );

Now save your plugin file and refresh the shop page in your browser.

![woocommerce product description](https://www.cloudways.com/blog/wp-content/uploads/shop-product-des.jpg)These descriptions are a bit long. To reduce the content length, add the following code in your functions.php located at theme folder.

1. function get\_ecommerce\_excerpt(){
2. $excerpt = get\_the\_excerpt();
3. $excerpt = preg\_replace(" (\[.\*?])",'',$excerpt);
4. $excerpt = strip\_shortcodes($excerpt);
5. $excerpt = strip\_tags($excerpt);
6. $excerpt = substr($excerpt, 0, 100);
7. $excerpt = substr($excerpt, 0, strripos($excerpt, " "));
8. $excerpt = trim(preg\_replace( '/s+/', ' ', $excerpt));
9. return $excerpt;
10. }

**$excerpt = substr($excerpt, 0, 100);** where 100 is character limit. you can manage content length by increasing and decreasing its value.

Further, replace the following function

1. the\_excerpt();

by

1. echo get\_ecommerce\_excerpt();

in your plugin file having name cloudways-product-shor-des.php

Now save your plugin file and refresh the shop page in your browser.

![woocommerce store production display](https://www.cloudways.com/blog/wp-content/uploads/short-des-shop-pge.jpg)

#### **Get WooCommerce product description by product\_id**

By the following code you can get WooCommerce product description or the product object using product ID

1. $order = wc\_get\_order($order\_id);
2. foreach ($order->get\_items() as $item) {
3. &#x20;$product\_id = $item\['product\_id'];
4. &#x20;$product\_details = $product->get\_data();
5. &#x20;$product\_full\_description = $product\_details\['description'];
6. &#x20;$product\_short\_description = $product\_details\['short\_description'];
7. }
8. By using wc\_get\_product, get\_description() and get\_short\_description()
9. $order = wc\_get\_order($order\_id);
10. foreach ($order->get\_items() as $item) {
11. &#x20;$product\_id = $item\['product\_id'];
12. &#x20;$product\_instance = wc\_get\_product($product\_id);
13. &#x20;$product\_full\_description = $product\_instance->get\_description();
14. &#x20;$product\_short\_description = $product\_instance->get\_short\_description();
15. }

#### **Wrapping up!**

Since WooCommerce outputs the greater part of its content utilizing hooks, it’s appropriate to include more content by writing functions and connecting them to those hooks. The tutorial demonstrates how to add a short description of the product at product archives.
