Product Page

WooCommerce Stock Quantity Suffix

WooCommerce product page showing custom content as a suffix

Pre-Requisites

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

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 10% off on your first month with us.

26027
WELCOME OFFER