How to change the Out of stock message in Woocommerce

How to change the Out of stock message in Woocommerce MENA Studio

How to change the Out of stock message in Woocommerce

Are you looking to customize the “out of stock” message displayed on your WooCommerce store? Whether you want to add a personal touch or match it to your branding, this simple code snippet will allow you to change the default message.

Step 1: Accessing Your WordPress Dashboard

First, log in to your WordPress dashboard.

Step 2: Navigating to the Theme Editor

In the WordPress dashboard, navigate to **Appearance > Theme Editor**.

Step 3: Editing the functions.php File

Once in the Theme Editor, locate the `functions.php` file on the right-hand side. This file contains functions that allow you to modify various aspects of your theme.

Step 4: Inserting the Code

Copy the following code snippet:

<?php
add_filter('woocommerce_get_availability_text', 'customwm_change_soldout', 10, 2 );

/**
* Change Sold Out Text
*/
function customwm_change_soldout ( $text, $product) {
if ( !$product->is_in_stock() ) {
$text = '<div class="custom-sold-m">Sold out.</div>';
}
return $text;
}
?>

Paste this code at the bottom of the `functions.php` file.

Step 5: Saving Changes

After pasting the code, click on the “Update File” button to save your changes.

 Step 6: Testing

Visit your WooCommerce store and navigate to a product that is currently out of stock. You should see the updated “out of stock” message according to the changes you’ve made.

Conclusion

Congratulations! You’ve successfully customized the “out of stock” message in WooCommerce. Feel free to modify the text within the code snippet to suit your preferences or branding. If you encounter any issues, you can easily revert the changes by removing the added code from the `functions.php` file.

Leave a Reply

Your email address will not be published. Required fields are marked *

You might also like

What is Wordpress? website webdesign MENA Studio Strona Wordpress

What is WordPress? A Comprehensive Guide

In the ever-evolving digital landscape, having a robust online presence is crucial for individuals and businesses alike. When it comes to creating a website or blog, WordPress has emerged as [...]
Read more

MENA Studio 2023 | All Rights Reserved | Designed with ❤️ by MENA Studio