wc_get_stock_html()
Get HTML to show product stock.
Hooks from the function
Return
String
.
Usage
wc_get_stock_html( $product );
- $product(WC_Product) (required)
- Product Object.
Changelog
Since 3.0.0 | Introduced. |
wc_get_stock_html() wc get stock html code WC 9.7.1
function wc_get_stock_html( $product ) { $html = ''; $availability = $product->get_availability(); if ( ! empty( $availability['availability'] ) ) { ob_start(); wc_get_template( 'single-product/stock.php', array( 'product' => $product, 'class' => $availability['class'], 'availability' => $availability['availability'], ) ); $html = ob_get_clean(); } if ( has_filter( 'woocommerce_stock_html' ) ) { wc_deprecated_function( 'The woocommerce_stock_html filter', '', 'woocommerce_get_stock_html' ); $html = apply_filters( 'woocommerce_stock_html', $html, $availability['availability'], $product ); } return apply_filters( 'woocommerce_get_stock_html', $html, $product ); }