Reputation:
I have seen examples on here where you add some text to the functions.php. However how would I change it from its current text which is
10 in stock to Only 10 left so that it keeps the quantity. And then when its sold out it says Sold Out
Upvotes: 2
Views: 2888
Reputation: 26329
Here's a quick way to change the "Out of Stock" text to "Sold Out"
function so_28107321_availability( $availability, $product ){
if( $availability['class'] == 'out-of-stock' ){
$availability['availability'] = 'Sold Out';
}
return $availability;
}
add_filter( 'woocommerce_get_availability', 'so_28107321_availability', 10, 2 );
The "10 left" will automatically switch to "Only 10 left" if the stock quantity is below the woocommerce_notify_low_stock_amount
option value. In your WooCommerce settings, you could set this value very high so that it would always say that.
Upvotes: 3