Change "Sold out" for certain products in WooCommerce

enter image description here

What I am trying to do is to change the standard WooCommerce Sold Out message and add something after it for just two types of products.

I decided I could try do it with JavaScript by changing the text that appears in the p element when it appears. I first do a window url check to see if we are on the right page, and if we are, then make sure the text doesn’t just say “UITVERKOCHT” but instead “UITVERKOCHT (neem contact op via contactformulier, levertijd 2 werkdagen).”

UITVERKOCHT shows when the product is sold out. But just for these two products, I want to add an extra message after UITVERKOCHT. So this is what I tried so far.

if(window.location.href.indexOf("prikkabel-50-meter") > -1 || window.location.href.indexOf("prikkabel-100-meter") > -1){
    jQuery( "#product-5666 > div.single-product-wrapper > div.summary.entry-summary > form > div > div.woocommerce-variation.single_variation > div.woocommerce-variation-availability > p" ).change(function() {
        console.log('a change occured');

Any idea what else I can try?

Read more here: Change "Sold out" for certain products in WooCommerce

Leave a Reply

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