Notice: These forums are now retired and closed. For active support, please Submit a Ticket or visit our official WordPress.org community pages.
Kadence Theme | Kadence Blocks | Starter Templates | WooCommerce Email Designer | Ascend | Virtue | Pinnacle

Sold badges and custom stock text

Home / Forums / Virtue Theme / Sold badges and custom stock text

This topic is: Resolved
[Resolved]
Posted in: Virtue Theme
September 15, 2015 at 7:24 am

Hello 🙂

I’ve noticed that if I change the “Out of Stock” text to something else, the Sold badge no longer appears on my product images. Is there a way I can get them to work with a custom message? I’ve been using this code in the functions file of my child theme to change the text:

/**
* Change In Stock / Out of Stock Text
*/
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;
}

Kind regards,

Phillip

  • The forum ‘Virtue Theme’ is closed to new topics and replies.