WooCommerce Stock Quantity Suffix

WooCommerce product page showing custom content as a suffix


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 guide allows you to add custom content to the stock quantity value. For example, you may wish to show the container of product units for example, “15 pallets in stock”, “15 boxes in stock”, “15 lbs in stock” etc. You may even wish to highlight if stock is inclusive of tax. With this snippet, you can literally output any content you like after the stock quantity.

 * Snippet Name:	WooCommerce Add Suffix To Stock Quantity
 * Snippet Author:	ecommercehints.com

add_filter( 'woocommerce_format_stock_quantity', 'ecommercehints_add_stock_quantity_suffix', 10, 2 );
function ecommercehints_add_stock_quantity_suffix($stock_quantity, $product) {
    $stock_quantity = $stock_quantity . " pallets ";
    return $stock_quantity;

Snippet Benefits

  • Display custom content as a suffix for stock quantity on the WooCommerce single product template
WooCommerce Conversion Rate Optimisation (CRO) eBook
100 WooCommerce Conversion Rate Optimisation Tips

Leave a Reply

If you are going to write code in the comments, please wrap it between code tags.

Your email address will not be published. Required fields are marked *

Other Recent Guides

Subscribe To Emails

Get exclusive WooCommerce tips that I only share with email subscribers

Join hundreds of other subscribers