How to Easily Change Out of Stock Text in WooCommerce

To change the “Out of Stock” text in WooCommerce easily, you can follow these steps:

Please note that the method described here may not require any coding skills, as it involves using a popular plugin called “Say What?” to replace the text without modifying any code.

  1. Install and activate the “Say What?” plugin:
    • Go to your WordPress dashboard.
    • Navigate to “Plugins” > “Add New.”
    • Search for “Say What?” and click “Install Now” next to the plugin with that name.
    • Once installed, click “Activate” to activate the plugin.
  2. Access the “Say What?” settings:
    • After activating the plugin, go to “Tools” > “Text changes” in your WordPress dashboard.
  3. Add a new text change rule:
    • Click on “Add New” to create a new text change rule.
  4. Configure the text change rule:
    • In the “Original string” field, enter the default “Out of Stock” text that WooCommerce displays when a product is out of stock.
    • In the “Text domain” field, enter woocommerce.
    • In the “Text context” field, enter Product status.
    • In the “Replacement string” field, enter the custom text you want to display when a product is out of stock (e.g., “Sold Out”).
  5. Save the changes:
    • Click on the “Add” button to save the text change rule.
  6. Clear any caching:
    • If you have caching enabled on your website, clear it to see the changes take effect immediately.

Now, when a product is out of stock on your WooCommerce store, it should display the custom text you specified using the “Say What?” plugin.

Changing the currency symbol (د.إ to AED) and tax label (VAT) for the UAE in Woocommerce

Keep in mind that using plugins for text replacements is a quick and user-friendly solution. However, if you prefer to make this change through code modifications, you can do it by creating a child theme and overriding the appropriate template files or using custom functions within your theme’s functions.php file.

To Change Out of Stock Text in WooCommerce Easily Without any plugin

To change the “Out of Stock” text in WooCommerce without using any plugins, you can do it by adding a simple code snippet to your theme’s functions.php file. Here’s how you can achieve this:

  1. Access your WordPress theme files:
    • Go to your WordPress dashboard.
    • Navigate to “Appearance” > “Theme Editor.”
    • On the right-hand side, find “Theme Files” and click on “Theme Functions (functions.php).”
  2. Add the code snippet:
    • Add the following code at the end of the functions.php file:
function change_woocommerce_out_of_stock_message( $text ) {
    $text = 'Sold Out'; // Replace 'Sold Out' with your desired custom text
    return $text;
}
add_filter( 'woocommerce_out_of_stock_message', 'change_woocommerce_out_of_stock_message' );
  1. Save the changes:
    • Click on the “Update File” button to save the changes to your functions.php file.
  2. Clear any caching:
    • If you have caching enabled on your website, clear it to see the changes take effect immediately.

Now, when a product is out of stock on your WooCommerce store, it should display the custom text you specified without the need for any plugins.

Please note that modifying theme files directly is not recommended, as it can be overwritten during theme updates. To ensure better compatibility and maintainability, it’s advisable to use a child theme or create a custom plugin to hold your customizations. If you’re not familiar with these methods, you can use the “Say What?” plugin as described in the previous answer.

How to earn money online

To Change Out of Stock Text on the Shop page on products images Easily

To Change Out of Stock Text on the Shop page
  1. Access your WordPress theme files:
    • Go to your WordPress dashboard.
    • Navigate to “Appearance” > “Theme Editor.”
    • On the right-hand side, find “Theme Files” and click on “Theme Functions (functions.php).”
  2. Add the co
    • Add the following code at the end of the functions.php file:
add_action( 'woocommerce_before_shop_loop_item_title', function() {
global $product;
if ( !$product->is_in_stock() ) {
echo '<span class="sold-out-overlay">sold out</span>';
}
});
  1. Save the changes:
    • Click on the “Update File” button to save the changes to your functions.php file.
  2. Customize CSS
    • Go to your WordPress dashboard.
    • Navigate to “Appearance” > “Customize”
  3. On the left-hand side, find “Theme Files” and add CSS Code:
.ast-shop-product-out-of-stock {
    display: none;
}

.sold-out-overlay {
    bottom: 1em;
    text-transform: uppercase;
    font-weight: 700;
    position: absolute;
    background-color: rgba(255,255,255,.88);
    transition: background .3s;
    text-align: center;
    left: 1em;
    right: 1em;
    padding: 0.5em 0 0.7em;
}

If you have caching enabled on your website, clear it to see the changes take effect immediately.

Now, when a product is out of stock on your WooCommerce store, it should display the custom text you specified without the need for any plugins.

Leave a Comment