Website Building » WooCommerce » How Do I Create an Out of Stock Badge in WooCommerce?

How Do I Create an Out of Stock Badge in WooCommerce?

Last updated on October 1, 2022 @ 2:58 pm

If you’re running a WooCommerce store, you’ve probably had the experience of selling an item that’s gone out of stock. When this happens, you need to let your customers know that the item is no longer available, and this is where an out of stock badge comes in.

There are a few different ways to create an out of stock badge in WooCommerce. The easiest way is to use a plugin like WooCommerce Out of Stock Badger. This plugin will automatically add an out of stock badge to any products that are out of stock.

If you don’t want to use a plugin, you can also add an out of stock badge to your products manually. To do this, you’ll need to edit the product template file for your theme. This file is typically called single-product.php or product.php.

Once you’ve found the correct file, you’ll need to add the following code:

is_in_stock() ) : ?>

PRO TIP: If you are planning to create an out of stock badge in WooCommerce, be aware that this can be a risky proposition. While it may seem like a good idea to mark products as “out of stock” when they are no longer available, this can actually lead to more problems than it solves. First of all, customers may see the “out of stock” badge and assume that the product is no longer available from the store, when in fact it may just be temporarily out of stock. This can lead to lost sales and disappointed customers. Additionally, the “out of stock” badge can make it difficult for customers to find the product they are looking for on your site. If you do decide to create an out of stock badge, be sure to use it sparingly and only on products that are truly out of stock.

This code will check to see if the product is in stock or not. If it’s not in stock, it will display an out of stock message. You can customize this message by changing the text inside the

tags.

Once you’ve added this code, save the file and upload it to your server. Your out of stock badge should now be appearing on all of your out of stock products!

Dale Leydon

Dale Leydon

Sysadmin turned Javascript developer. Owner of 20+ apps graveyard, and a couple of successful ones.