I am trying to change the in stock text next to the quantity available in woocommerce. I am using the stock management in product variations.
I tried this code below:
// change stock text
add_filter( 'woocommerce_get_availability', 'wcs_custom_get_availability', 1, 2);
function wcs_custom_get_availability( $availability, $variation ) {
// Change In Stock Text
if ( $variation->is_in_stock() ) {
$availability['availability'] = __('Available!', 'woocommerce');
}
// Change Out of Stock Text
if ( ! $variation->is_in_stock() ) {
echo '-------------------------';
echo __('Sold Out', 'woocommerce');
$availability['availability'] = __('Sold Out', 'woocommerce');
}
return $availability;
}
The code above changes the text but it does not pull in the stock quantity number from the variation stock manager.
Any help is appreciated.