Display product description in WooCommerce Website


website-marketing-products-deals-woocommerce

Display product description in WooCommerce Website - WooCommerce is packed with an archive page with a loop that helps show great WooCommerce product descriptions. However, here or there you need to display more data at the main website and other hosting sites. This article shows how to display a short description of the WooCommerce product with the hosting page, showing it below the product title. You also add the minimum shipping requirement rule at the product.


Create a WooCommerce product description plugin


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


Open the file at the code editor manager. At the top of the file, include:


display-website-brand-website-thuong-mai-woocommerce


This sets up the plugin, providing WordPress with everything it needs to get it activated.


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


display-website-brand-website-thuong-mai-woocommerce


Now Activate WooCommerce product description plugin.


At first, it will not work when you have not immigrated. This is what the website looks like at the moment:


display-website-brand-website-thuong-mai-woocommerce


Functionality to get WooCommerce short description


Short description of the product at WooCommerce using the excerpts you find at the regular post. So to display it, you only need to display excerpts for the post.


In the plugin file you own, add the code to get a WooCommerce product description:


display-website-brand-website-thuong-mai-woocommerce


It is basically that! However, now you must append the function you have to the correct operation so that it outputs at the correct location on the hosting page you manage.


See more: .Htaccess file in WordPress


Functional function for the correct action to add a WooCommerce short description


How about we investigate files at WooCommerce exporting loop content at archive page? This file is content-product.php, you see it in the sample folder of the WooCommerce plugin using the WooCommerce product description hook. Different action hook combination files, all of which are used by WooCommerce to export different content.


Because we need to display the excerpt below the product title, the hook we have to use is WooCommerce_after_shop_loop_item_title. As you can see from content-product.php, it now has two attached functions, WooCommerce_template_loop_rating () and WooCommerce_template_loop_price (), which have separate priority levels of 5 and 10. So we need to join The function we have has a higher priority number, to make sure it runs after that function. I will leave some time and using 40 is preferred.


Below the function, add this:


display-website-brand-website-thuong-mai-woocommerce


Now the complete WooCommerce description code becomes:


display-website-brand-website-thuong-mai-woocommerce


Now save the plugin file and then refresh the website in your browser.


display-website-brand-website-thuong-mai-woocommerce


These descriptions are a bit long. To reduce the content length, add the following code to the function.php located in the interface directory.


display-website-brand-website-thuong-mai-woocommerce


$ excerpt = base ($ extract, 0, 100); where 100 is the character limit, you manage the content length by increasing or decreasing the value.


Moreover, replace the following function


display-website-brand-website-thuong-mai-woocommerce


By


display-website-brand-website-thuong-mai-woocommerce


Now save the plugin file and then refresh the website in your browser.


display-website-brand-website-thuong-mai-woocommerce


Get WooCommerce product description by product_id


Following the code below, you get the WooCommerce product description, product object by product ID


display-website-brand-website-thuong-mai-woocommerce


Wrapped again!


Because WooCommerce makes the most of its content using hooks from it, it is appropriate to include more content by writing functions and then connecting them to that hook. The guide demonstrates how to add a short description of the product at the product storage. If you have any questions about the related issues, ask in the comments.