change ‘out of stock’ text
-
I’m trying to change the ‘out of stock’ ribbon on product thumbnails and within the product page to say ‘sold’. I’ve tried adding below codes to functions.php but neither worked. Any help with this really appreciated. (note I have twi product carousel installed and i wonder if this is affecting it at all).
Thanks
code 1:
add_filter( ‘woocommerce_get_availability’, ‘wcs_custom_get_availability’, 1, 2);
function wcs_custom_get_availability( $availability, $_product ) {// Change In Stock Text
if ( $_product->is_in_stock() ) {
$availability[‘availability’] = __(‘Available!’, ‘woocommerce’);
}
// Change Out of Stock Text
if ( ! $_product->is_in_stock() ) {
$availability[‘availability’] = __(‘Sold’, ‘woocommerce’);
}
return $availability;
}Code 2
function availability_filter($availability) {
$availability[‘availability’] = str_ireplace(‘Out of stock’, ‘SOLD’, $availability[‘availability’]);
return $availability;
}
add_filter(‘woocommerce_get_availability’, ‘availability_filter’);The page I need help with: [log in to see the link]
- The topic ‘change ‘out of stock’ text’ is closed to new replies.