I, like many people have wanted attributes to be able to be 'switched off' instead of having to delete them, and re-install them when a product in a certain size or spec is out of stock, or have it labelled 'out of stock' so customers know that options may be available in the future.
Well, this was never possible, but I've put a hack on my own sites which allows this is happen in a roundabout way.
1. Add this following script to your html_header.php file.
<script language="javascript" type="text/javascript">
function replaceWord(control, oldWord, newWord) {
var pageElement = document.getElementById(control);
oldWord = new RegExp(oldWord, "g");
if (pageElement.value)
pageElement.value = pageElement.value.replace(oldWord, newWord);
else
pageElement.innerHTML = pageElement.innerHTML.replace(oldWord, newWord);
}
</script>
<body onload="replaceWord('productAttributes', '£999.00', 'Out Of Stock')" />
(Note above : Make the currency above match the one on your site, mine is UK hence the £'
2. Mark your attributes you want to appear out of stock, as 'display only' (so they cannot be added to basket)
3. Make the add on price of that attribute '999'
Thats it. What this javascript does is string replace text on the screen, so when it detects £999.00 it swaps the text for 'Out of stock'
So now when the customer views the drop down menu, it lists the size/spec with 'Out of stock' next to it, and it cannot be added to basket. To make it in stock again, simply mark as not display only and remove the price markup.


Reply With Quote
