{"id":3361,"date":"2018-10-05T01:43:52","date_gmt":"2018-10-05T01:43:52","guid":{"rendered":"https:\/\/docs.contentviewspro.com\/?p=3361"},"modified":"2023-12-27T09:02:57","modified_gmt":"2023-12-27T09:02:57","password":"","slug":"woocommerce-show-out-of-stock-text-on-products","status":"publish","type":"docs","link":"https:\/\/contentviewspro.com\/documentation\/article\/woocommerce-show-out-of-stock-text-on-products\/","title":{"rendered":"WooCommerce \u2013 show &#8220;In stock&#8221;, &#8220;Out of stock&#8221;, &#8220;On Backorder&#8221; text on products"},"content":{"rendered":"<p>Content Views Pro helps you to show WooCommerce products in grid and list layout easily.<br \/>\nYou might want to show in stock, out of stock, on backorder status for your products.<br \/>\nTo do that, please add this code to file <strong>functions.php<\/strong> in the theme&#8217;s folder (or install this plugin <a href=\"https:\/\/wordpress.org\/plugins\/code-snippets\/\" rel=\"nofollow\">Code Snippets<\/a> then add this code to <a href=\"https:\/\/ps.w.org\/code-snippets\/assets\/screenshot-2.png\" rel=\"nofollow\">the &#8220;Code&#8221; textarea<\/a>):<\/p>\n<pre style=\"font-size:13px\">\n\/\/ Content Views Pro - Woocommerce: Display product status\nadd_action( 'pt_cv_item_extra_html', 'cvp_item_extra_html_wofs' );\nfunction cvp_item_extra_html_wofs( $post_id ) {\n\t$product = wc_get_product( $post_id );\n\tif ( is_object( $product ) ) {\n\n\t\t\/\/ Out of stock\n\t\tif ( !$product-&gt;is_in_stock() ) {\n\t\t\techo '&lt;div class=&quot;out-of-stock&quot;&gt;Out of stock&lt;\/div&gt;';\n\t\t}\n\n\t\t\/\/ In Stock\n\t\tif ( $product-&gt;is_in_stock() ) {\n\t\t\techo '&lt;div class=&quot;in-stock&quot;&gt;In stock&lt;\/div&gt;';\n\t\t}\n\n\t\t\/\/ On Backorder\n\t\tif ( $product-&gt;is_on_backorder() ) {\n\t\t\techo '&lt;div class=&quot;on-backorder&quot;&gt;On Backorder&lt;\/div&gt;';\n\t\t}\n\n\t}\n}\n<\/pre>\n<p>Best regards,<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Content Views Pro helps you to show WooCommerce products in grid and list layout easily. You might want to show in stock, out of stock, on backorder status for your products. To do that, please add this code to file functions.php in the theme&#8217;s folder (or install this plugin Code Snippets then add this code &hellip;<\/p>\n<p class=\"read-more\"> <a class=\"\" href=\"https:\/\/contentviewspro.com\/documentation\/article\/woocommerce-show-out-of-stock-text-on-products\/\"> <span class=\"screen-reader-text\">WooCommerce \u2013 show &#8220;In stock&#8221;, &#8220;Out of stock&#8221;, &#8220;On Backorder&#8221; text on products<\/span> Read More &raquo;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"default","site-content-layout":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"","ast-breadcrumbs-content":"","ast-featured-img":"","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","footnotes":""},"doc_category":[50],"doc_tag":[21,20],"class_list":["post-3361","docs","type-docs","status-publish","hentry","doc_category-woocommerce","doc_tag-custom-code","doc_tag-woocommerce"],"year_month":"2026-09","word_count":171,"total_views":"2","reactions":{"happy":"0","normal":"0","sad":"0"},"author_info":{"name":"admin1","author_nicename":"admin1","author_url":"https:\/\/contentviewspro.com\/documentation\/author\/admin1\/"},"doc_category_info":[{"term_name":"WooCommerce","term_url":"https:\/\/contentviewspro.com\/documentation\/cats\/woocommerce\/"}],"doc_tag_info":[{"term_name":"custom PHP code","term_url":"https:\/\/contentviewspro.com\/documentation\/tags\/custom-code\/"},{"term_name":"WooCommerce","term_url":"https:\/\/contentviewspro.com\/documentation\/tags\/woocommerce\/"}],"_links":{"self":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/3361","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/comments?post=3361"}],"version-history":[{"count":1,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/3361\/revisions"}],"predecessor-version":[{"id":5371,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/docs\/3361\/revisions\/5371"}],"wp:attachment":[{"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/media?parent=3361"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_category?post=3361"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/contentviewspro.com\/documentation\/wp-json\/wp\/v2\/doc_tag?post=3361"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}