woocommerce_stock_amount хук-фильтрWC 2.3

Filter the stock amount. If an invalid value is returned by hooks, falls back to intval( $amount ).

Использование

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.

Список изменений

С версии 2.3 Введена.

Где вызывается хук

wc_stock_amount()
woocommerce_stock_amount
woocommerce/includes/wc-formatting-functions.php 500
return NumberUtil::normalize( apply_filters( 'woocommerce_stock_amount', $amount ), intval( $amount ) );

Где используется хук в WooCommerce

woocommerce/includes/wc-core-functions.php 46
add_filter( 'woocommerce_stock_amount', 'intval' ); // Stock amounts are integers by default.