Product Page

WooCommerce Add Stock Quantity Prefix

WooCommerce product page showing custom stock quantity prefix


There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

This snippet allows you to add any custom prefix to the stock quantity shown on the single product template. In this particular example, we’ve added “Relax…there are” as the prefix.

 * Snippet Name:	WooCommerce Add Prefix To Stock Quantity
 * Snippet Author:

add_filter( 'woocommerce_format_stock_quantity', 'ecommercehints_add_stock_quantity_prefix', 10, 2 );
function ecommercehints_add_stock_quantity_prefix($stock_quantity, $product) {
    $stock_quantity = 'Relax...there are ' . $stock_quantity;
    return $stock_quantity;

Snippet Benefits

  • Show any custom content you like as a prefix to the stock quantity on the WooCommerce single product template

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.