WordPress filter hook

woocommerce_stock_html

Defined by WooCommerce and fired by 17 plugins in total, running on 7.7M+ sites between them.

How to use woocommerce_stock_html

It's a filter: your callback receives the value and 2 more arguments, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'woocommerce_stock_html', function( $stock_html, $kses_post, $product ) {
	// Change $stock_html here.
	return $stock_html;
}, 10, 3 );

Argument names come from Royal Addons for Elementor's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

17 plugins that fire woocommerce_stock_html

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WooCommerce icon WooCommerce7+ million installs apply_filters( 'woocommerce_stock_html', $html, $availability['availability'], $product ) includes/wc-template-functions.php:4364
  2. Royal Addons for Elementor icon Royal Addons for Elementor600,000+ installs apply_filters( 'woocommerce_stock_html', $stock_html, wp_kses_post($availability['availability']), $product ) modules/theme-builder/woocommerce/product-stock/widgets/wpr-product-stock.php:409
  3. ShopEngine icon ShopEngine90,000+ installs apply_filters( 'woocommerce_stock_html', $stock_html, $availability_html, $product ) widgets/product-stock/screens/default.php:113
  4. Spexo Addons for Elementor icon Spexo Addons for Elementor6,000+ installs apply_filters( 'woocommerce_stock_html', $stock_html, wp_kses_post($availability['availability']), $product ) inc/widgets/woo-product-stock.php:449
  5. WowStore icon WowStore4,000+ installs apply_filters( 'woocommerce_stock_html', $stock_html, $availability['availability'], $product ) blocks/woo/Product_Stock.php:55
  6. ShopEngine Gutenberg WooCommerce Builder Blocks Addon icon ShopEngine Gutenberg WooCommerce Builder Blocks Addon3,000+ installs apply_filters( 'woocommerce_stock_html', $stock_html, wp_kses_post($availability['availability']), $product ) blocks/product-stock/screen.php:66
  7. Products Compare for WooCommerce icon Products Compare for WooCommerce1,000+ installs apply_filters( 'woocommerce_stock_html', $availability_html, $term['availability']['availability'], $product ) templates/new-compare.php:413
  8. CRT Addons Builder and Widgets for Elementor icon CRT Addons Builder and Widgets for Elementor300+ installs apply_filters( 'woocommerce_stock_html', $stock_html ?? '', $availability['availability'] ?? '', $product ) includes/customizer/addons/modules/woocommerce/crt-product-stock.php:405
  9. Salevo Boost Sales for WooCommerce icon Salevo Boost Sales for WooCommerce200+ installs apply_filters( 'woocommerce_stock_html', $availability_html, $availability['availability'], $product ) templates/single-product/add-to-cart/wbs-bundle.php:22
  10. Wishlist and Waitlist for WooCommerce icon Wishlist and Waitlist for WooCommerce100+ installs apply_filters( 'woocommerce_stock_html', $availability_html, $term['availability']['availability'], $product ) includes/functions.php:22
  11. ShopMaker icon ShopMaker90+ installs apply_filters( 'woocommerce_stock_html', $availability_html, $availability['availability'], $wc_product ) classes/widgets/wishlist/sm-wishlist-products.php:599
  12. Wholesale Order Table for WooCommerce icon Wholesale Order Table for WooCommerce70+ installs apply_filters( 'woocommerce_stock_html', $availability_html, $availability['availability'], $product ) classes/class-otfw-product.php:777
  13. Reactor: Core icon Reactor: Core30+ installs apply_filters( 'woocommerce_stock_html', $availability_html, $availability['availability'], $product ) inc/api/v1/templates/woo/add-to-cart/grouped.php:53
  14. Elite Elementor Addons and Widgets icon Elite Elementor Addons and Widgets20+ installs apply_filters( 'woocommerce_stock_html', $stock_html, wp_kses_post($availability['availability']), $product ) modules/theme-builder/woocommerce/product-stock/widgets/elite-product-stock.php:409
  15. WooLayout icon WooLayout10+ installs apply_filters( 'woocommerce_stock_html', $availability_html, $availability['availability'], $product ) lib/woolayout/single-product/add-to-cart/grouped.php:80
  16. Products Wizard Lite for WooCommerce icon Products Wizard Lite for WooCommerce10+ installs apply_filters( 'woocommerce_stock_html', $availabilityHtml, $availability['availability'], $this->product ) includes/classes/Instances/FormProduct.php:179
  17. RedQ Events icon RedQ Events10+ installs apply_filters( 'woocommerce_stock_html', '<p class="stock ' . esc_attr( $availability['class'] ) . '">' . esc_html( $availability['availability'] ) . '</p>', $availability['availability'] ) templates/single-product/add-to-cart/event.php:29

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.