VIA BUSINESS BLOOMERS

WooCommerce: Stock Quantity Suffix e.g. “sq. in.”, “Kg”, “boxes”, etc.

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!

"use strict"; var adace_load_62887674c779d = function(){ var viewport = $(window).width(); var tabletStart = 601; var landscapeStart = 801; var tabletEnd = 961; var content = '%3Cdiv%20class%3D%22adace_adsense_62887674c75a2%22%3E%3Cscript%20async%20src%3D%22%2F%2Fpagead2.googlesyndication.com%2Fpagead%2Fjs%2Fadsbygoogle.js%22%3E%3C%2Fscript%3E%0A%09%09%3Cins%20class%3D%22adsbygoogle%22%0A%09%09style%3D%22display%3Ablock%3B%22%0A%09%09data-ad-client%3D%22ca-pub-9250614219462833%22%0A%09%09data-ad-slot%3D%224692840435%22%0A%09%09data-ad-format%3D%22horizontal%22%0A%09%09%3E%3C%2Fins%3E%0A%09%09%3Cscript%3E%28adsbygoogle%20%3D%20window.adsbygoogle%20%7C%7C%20%5B%5D%29.push%28%7B%7D%29%3B%3C%2Fscript%3E%3C%2Fdiv%3E'; var unpack = true; if(viewport=tabletStart && viewport=landscapeStart && viewport=tabletStart && viewport=tabletEnd){ if ($wrapper.hasClass('.adace-hide-on-desktop')){ $wrapper.remove(); } } if(unpack) { $self.replaceWith(decodeURIComponent(content)); } } if($wrapper.css('visibility') === 'visible' ) { adace_load_62887674c779d(); } else { //fire when visible. var refreshIntervalId = setInterval(function(){ if($wrapper.css('visibility') === 'visible' ) { adace_load_62887674c779d(); clearInterval(refreshIntervalId); } }, 999); }

})(jQuery);

In this example, I’ve added “m2” suffix to the stock quantity on the WooCommerce Single Product Page. Easy peasy with the PHP snippet below!

PHP Snippet: Stock Quantity Suffix @ WooCommerce Single Product Page

/**
 * @snippet       Stock Quantity Suffix @ WooCommerce Single Product
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 5
 * @donate $9     https://businessbloomer.com/bloomer-armada/
 */

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;
}

WooCommerce: Stock Quantity Suffix e.g. “sq. in.”, “Kg”, “boxes”, etc. .

mersin escortmersin escort