Skip to content

Instantly share code, notes, and snippets.

@lwgists
Forked from claudiosanches/functions.php
Created January 11, 2018 15:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lwgists/e6cb4e63dff6b42bc1d626395e6d8399 to your computer and use it in GitHub Desktop.
Save lwgists/e6cb4e63dff6b42bc1d626395e6d8399 to your computer and use it in GitHub Desktop.
WooCommerce - Hide the "In stock" message on product page.
<?php
/**
* Hide the "In stock" message on product page.
*
* @param string $html
* @param string $text
* @param WC_Product $product
* @return string
*/
function my_wc_hide_in_stock_message( $html, $text, $product ) {
$availability = $product->get_availability();
if ( isset( $availability['class'] ) && 'in-stock' === $availability['class'] ) {
return '';
}
return $html;
}
add_filter( 'woocommerce_stock_html', 'my_wc_hide_in_stock_message', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment