Skip to content

Instantly share code, notes, and snippets.

@shameemreza
Created April 14, 2024 05:08
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 shameemreza/3868f585994d27be41756405fa70db20 to your computer and use it in GitHub Desktop.
Save shameemreza/3868f585994d27be41756405fa70db20 to your computer and use it in GitHub Desktop.
Consistently display the stock status on the Single Product page in WooCommerce
add_filter( ‘woocommerce_get_availability’, ‘custom_override_get_availability’, 10, 2);
// The hook in function $availability is passed via the filter!
function custom_override_get_availability( $availability, $_product ) {
if ( $_product->is_in_stock() ) $availability[‘availability’] = __(‘In stock’, ‘woodmart’);
return $availability;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment