Hi all,
There are throughout the forum various posts and requests for the ability to not show out-of-stock and/or unpublished items on the shop front-end.
This is a feature that I had a need for and after making enquiries through the forum, and with help from Nicolas, I produced an over-ride to accomplish this very task.
Fot those of you who have the need/desire to not show unpublished/out-of-stock items, as well as others that need a working example of an override to see how it is done, I attach a zipped copy the the code I produced.
The code only overrides drop-down/radio button displays - there is no handling for table display - and I haven't tried/tested it with radio buttons. If table display is being used then the existing Hikashop code will continue to handle the display.
It is supplied without any warranty and no responsibility will be accepted for any issues that may arise, either directly or indirectly, from its use. Having said that I can confirm that it is currently in use on a live installation and is performing as expected.
Feel free to modify the code, but please leave the copyright message intact and, ideally, share the resulting code.
The override should be unzipped and placed into:
templates/YOUR_TEMPLATE/html/
As it stands It only looks at the stock level of a product. If an unpublished item has a stock level (but why should it?) then it will be displayed. Just make sure that unpublished items have a zero stock level.
If the default size is out of stock then the first size it finds that has stock will be displayed on the front end as the default size. No change is made to the default - when it is back in stock it will be shown as the default.
If all items are out of stock then the "Out of stock" message will be shown.
One thing to be aware of is that if an item is out of stock it is not displayed as a size option, therefore, if you are using the 'email me when back in stock' option, it will not show for the out of stock size. With the size not being displayed the customer will not know that it is a stock (albeit out of stock) item. The 'email me' message will only be displayed when ALL the sizes are out of stock.
I hope you find the code useful. Please share any mods and findings in it use.
Regards,
Martyn.