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:
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:
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: