wc_format_stock_quantity_for_display

Format the stock quantity ready for display.

Description

(string) wc_format_stock_quantity_for_display( (int) $stock_quantity, (WC_Product) $product ); 

Returns (string)

Parameters (2)

0. $stock_quantity (int)
The stock quantity.
1. $product (WC_Product)
So that we can pass through the filters.

Usage

  1. if ( !function_exists( 'wc_format_stock_quantity_for_display' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'woocommerce/includes/wc-formatting-functions.php'; 
  3.  
  4. // The stock quantity. 
  5. $stock_quantity = -1; 
  6.  
  7. // so that we can pass through the filters. 
  8. $product = null; 
  9.  
  10. // NOTICE! Understand what this does before running. 
  11. $result = wc_format_stock_quantity_for_display($stock_quantity, $product); 
  12.  

Defined (1)

The function is defined in the following location(s).

/includes/wc-formatting-functions.php  
  1. function wc_format_stock_quantity_for_display( $stock_quantity, $product ) { 
  2. return apply_filters( 'woocommerce_format_stock_quantity', $stock_quantity, $product );