Search the site:

Home Blog Facebook Group Question: How to move “Out of stock” label to show below the WooCommerce product title?

Facebook Group Question: How to move “Out of stock” label to show below the WooCommerce product title?

This question was asked on the Facebook group: WooCommerce Help & Share.

Exact question: Does anyone know how to modify PHP to move the “out of stock” label on each individual item page? I want to move it to show up directly under the product title where the price normally is displayed.

Answer:

By default, below is how the “Out of stock” label is shown:

Display out of stock label below WooCommerce product title - Out of stock label shown below WooCommerce product price

You will need to modify 2 template files of WooCommerce. You can overwrite them by simply copying those files at the same path within your active theme & then making the changes mentioned below:

The path of the template files should be mapped as shown below:

wp-content/plugins/woocommerce/templates

Should be:

wp-content/themes/<your theme>/woocommerce/

So after copying the template files, my folder structure looks like this:

Display out of stock label below WooCommerce product title - Template files path in active theme

To remove label from under the price

Remove the below line from the template file: woocommerce/single-product/add-to-cart/simple.php

echo wc_get_stock_html( $product );

To display label under the title

Add below 2 lines at end of the template file: woocommerce/single-product/title.php

global $product;
echo wc_get_stock_html( $product );

The result is:

Display out of stock label below WooCommerce product title - Out of stock label showing below WooCommerce product title

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

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