Out Of Stock Badge

Are you looking for a way to add a badge to show that a product is Out Of Stock in WooCommerce? This code snippet will allow you to add the functionality to allow your customers to easily see that a product is currently out of stock. You can completely tailor the wording of the button and the descriptive text to or colour schemes to show the users that the product is out of stock, on the shop page.

 

To do this you need to:

  1. Open WordPress admin panel, go to Appearance > Theme Editor.
  2. Open functions.php theme file.
  3. Add the following code at the bottom of function.php file of your child theme.
  4. Save the changes and check your website. Note that you can change the text included from ‘Proceed Now’ to whatever you wish. The custom text in proceed to checkout text will now be displayed.

Note:

To change the proceed to checkout button, ensure that you take a backup and only do this through your child theme so that future updates to your theme will not overwrite the code.

//START OF CODE


/**
*Out Of Stock Badge in WooCommerce
*   Add this code in your active theme functions.php file
**/

 

 

 

add_action( ‘woocommerce_before_single_product_summary’, function() {

global $product;

if ( !$product->is_in_stock() ) {

echo ‘<span class=”now_sold”>Sold Out</span>’;

}

});

//END OF CODE

If you prefer to changing the “Out Of Stock Badge” button text via a plugin, use these buttons to download our plugin, for free.

If you would like help with changing the “Free Of Charge Badge” or any website design project, please contact us – happy to help, always.

Social Media

 

Payments Accepted

 

payment options

Request a Callback

 

Contact Details

Phone: 01 536 3049

Mobile: (087) 13 77 382

Email: info@arrowdesign.ie

Address:

The Chase, Arkle Rd,

Sandyford, Dublin 18,

D18 Y3X2