Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save woogists/1e320cf196e9f09212989b0c5c7791c2 to your computer and use it in GitHub Desktop.
Save woogists/1e320cf196e9f09212989b0c5c7791c2 to your computer and use it in GitHub Desktop.
Display that a product is in stock even if Track Stock Quantity is not enabled under the product's Inventory tab.
<?php
add_filter( 'woocommerce_get_availability', 'custom_override_woocommerce_show_in_stock', 10, 2 );
function custom_override_woocommerce_show_in_stock( $availability, $product ) {
if ( ! $product->managing_stock() && $product->is_in_stock() ) {
$availability['availability'] = __( 'In Stock', 'woocommerce' );
}
return $availability;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment