Out of stock variable product default text
Question
I need to change the text of “In stock” and “Out of stock” variable products.
I used this code:
// 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;
}
It works fine for the available product, but not for the out-of-stock one.
0
woocommerce
4 years
2020-05-17T05:10:22-05:00
2020-05-17T05:10:22-05:00 0 Answers
81 views
0
Leave an answer