I need to change the “# in stock” text to “# deals left“.
I added the following code to the function.php file but this removes the actual number.
add_filter( 'woocommerce_get_availability', 'custom_get_availability', 1, 2);
function custom_get_availability( $availability, $_product ) {
//change text "In Stock' to 'SPECIAL ORDER'
if ( $_product->is_in_stock() ) $availability['availability'] = __('SPOTS LEFT', 'woocommerce');
//change text "Out of Stock' to 'SOLD OUT'
if ( !$_product->is_in_stock() ) $availability['availability'] = __('SOLD OUT', 'woocommerce');
return $availability;
}
Can anybody help with this?
you can try below code:
This works better in WC > 3.0. Just change get_total_stock to get_stock_quantity