Change script depending, if the product is in stock and or not in stock

Kiwicarparts
Visitor
2 0 0

Hi guys,

I have a script for showing when product will be dispatched:

{{ '//cdnjs.cloudflare.com/ajax/libs/datejs/1.0/date.min.js' | script_tag }}


<script>
var fromDate = Date.today().addDays(1);
if (fromDate.is().saturday() || fromDate.is().sunday()) {
fromDate = fromDate.next().monday();
}
var toDate = Date.today().addDays(3);
if (toDate.is().saturday() || toDate.is().sunday())
toDate = toDate.next().monday();


document.getElementById('fromDate').innerHTML = fromDate.toString('dddd MMMM dS');
document.getElementById('toDate').innerHTML = toDate.toString('dddd MMMM dS');
</script>

It needs to be only shown, if product.description does not contain :

"BUY NOW TO PRE-ORDER!" words. As we have some products in stock and pre-order.

Can anyone help how to change this script properly?

Thanks

Replies 0 (0)