fbpx
Want To Add Extra Images Per Product Variation For Free? Download Now

Change “Out of stock” text

David Fox

When an out of stock variation is selected, we see the message “Out of stock”. How do we change this text to “Sorry, that option is out of stock”.

Hakik Zaman

Hi David,

This is a default text from WooCommerce.

Please paste the below code inside your child theme’s functions.php or as a snippet inside the Code Snippets plugin

function change_out_of_stock_text_woocommerce( $availability, $product_to_check ) {

   // Change Out of Stock Text
   if ( ! $product_to_check->is_in_stock() ) {

      $availability['availability'] = __('Sorry, that option is out of stock', 'woocommerce');

   }
   return $availability;
}
add_filter( 'woocommerce_get_availability', 'change_out_of_stock_text_woocommerce', 1, 2);

Thank You