WooCommerce Sold Out badge

Reader Interactions

Comments

  1. Thank you, this is exactly what I need it. it works perfect. I changed the “sold out” text for “coming soon”, easy to adapt.

  2. Hi

    Thank you for this post, very helpful.

    I wonder if you could suggest a fix? I did everything as you said, but on my product page the badge floats in the header to the right, and also the badge displays over the title. My store is http://shop.kandagadgets.com if you could possibly advise?

    Many thanks for your time and help

    • It’s hard to say how to fix this without an example. Maybe you can try a different hook or you have to add position relative to the product div.

  3. Somehow this doesnt work right in case of variable products. Its shows the badge even if some variables (like size or color) are on stock and some are not

  4. Nevermind, i had the option “Enable stock management at product level” enabled… 😀 my fault. Works ok now.

  5. Hello
    The code is great
    How to translate it whit polylang or Loco translate?
    Thanks
    Greetings

  6. Thanks for the quick snippet. One buggy issue (def on my end):

    //* Add sold out badge on archive pages
    add_action( 'woocommerce_before_shop_loop_item_title', function() {
    global $product;
    if ( !$product->is_in_stock() ) {
    echo 'Sold out';
    }
    });

    The above snippet doesn’t display on every product that is sold out on the shop page, only the 2nd snippet that shows on every product page is working properly.