If like me you don’t use the stock features in Zen Cart then it’s very annoying how you cannot de-active a product attribute until it comes back into stock. This means you have to delete the attribute then re-add it back in when stocks arrive.

What I currently do is add some text in red letter telling the customer if a certain size, colour, etc is out of stock and leave the attribute in. The problem with that is customer hardly ever read descriptions! I can have a big red BLUE IS OUT OF STOCK, but some will still buy one.

Today I discovered a nice little hack to prevent a customer adding an out of stock item to the cart.
Basically it utilities the Display Only option in the Attributes Controller. If you use this option then this hack will interfere with that.
You can set the attribute as Display Only by clicking the icon then when a customer tries to add it to the cart zen cart prevents it with a bright notice at the top.
So all we need to do is alter the language file to say “you picked and out of stock item” rather than “you picked an invalid item” and bobs your uncle!

So here’s how to change the language file:

Open includes\languages\english.php
Search for define(‘TEXT_INVALID_SELECTION’,’ You picked an Invalid Selection: ‘); around line 453 in 1.3.7
Replace the wording you want i.e. define(‘TEXT_INVALID_SELECTION’,’ You picked an Out of Stock Item: ‘);

You can also change the layout a little in includes\classes\shopping_cart.php
Look for $the_list .= TEXT_ERROR_OPTION_FOR . around line 1569 in 1.3.7 and change the stuff after it to how you want (make sure you know what you are doing before editing this bit).

You can also change the background colour and text of the error by changing the messageStackCaution class in your stylesheet.css file.

An here is a screen shot of how I’ve made mine look on one of my shops Funky Petz:

BubbleShare: Share photosThanksgivingtime!