Each WooCommerce business is different, which means customization is required to adapt the store to unique specifications.
A clear example is the stock quantity. Not all stores can display the standard notice “11 in stock”. The display could change to “11 Kg in stock” if stock is based on weight. Or maybe “11 boxes in stock” or “11 pairs in stock” in case the package description is useful UX-wise. Also, “11 m3 in stock” if the business sells volumes.
Either way, this is a nice trick to display a “stock quantity suffix” in your WooCommerce Single Product Page. Enjoy!
PHP Snippet: Stock Quantity Suffix @ WooCommerce Single Product Page
/**
* @snippet Stock Quantity Suffix @ WooCommerce Single Product
* @how-to businessbloomer.com/woocommerce-customization
* @author Rodolfo Melogli, Business Bloomer
* @compatible WooCommerce 5
* @community https://businessbloomer.com/club/
*/
add_filter( 'woocommerce_format_stock_quantity', 'bbloomer_stock_quantity_suffix', 9999, 2 );
function bbloomer_stock_quantity_suffix( $stock_quantity, $product ) {
$stock_quantity .= ' m<sup>2</sup>'; // CONCATENATE " m2"
return $stock_quantity;
}