woocommerce_stock_amount
Filter the stock amount. If an invalid value is returned by hooks, falls back to intval( $amount ).
Usage
add_filter( 'woocommerce_stock_amount', 'wp_kama_woocommerce_stock_amount_filter' );
/**
* Function for `woocommerce_stock_amount` filter-hook.
*
* @param int|float $amount Stock amount.
*
* @return int|float
*/
function wp_kama_woocommerce_stock_amount_filter( $amount ){
// filter...
return $amount;
}
- $amount(int|float)
- Stock amount.
Changelog
| Since 2.3 | Introduced. |
Where the hook is called
woocommerce_stock_amount
woocommerce/includes/wc-formatting-functions.php 499
return NumberUtil::normalize( apply_filters( 'woocommerce_stock_amount', $amount ), intval( $amount ) );
Where the hook is used in WooCommerce
woocommerce/includes/wc-core-functions.php 44
add_filter( 'woocommerce_stock_amount', 'intval' ); // Stock amounts are integers by default.