- Posts: 57
- Thank you received: 2
Out of Stock / Unpublished Stock Levels
- expertbeginner
-
Topic Author
- Offline
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.
Please Log in or Create an account to join the conversation.
Thank you for sharing your override.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
We don't have a copy on our end.
We'll have to wait for expertbeginner to post it again.
Please Log in or Create an account to join the conversation.
- expertbeginner
-
Topic Author
- Offline
- Posts: 57
- Thank you received: 2
It appears that a .html extension is being added to the filename - I've just downloaded (right click on file and download), the file removed the .html extension and unzipped it okay.
I've attached a new copy.
Regards,
Martyn.
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.
I do not understand where you have to locate the code:
I inserted it in the folder:
templates / your_template / html /
And I do not find any changes.
Really do not know I'm doing wrong, if you can help me I appreciate it.
thank you very much for your job
Please Log in or Create an account to join the conversation.
That should remove the out of stock variants from the dropdowns.
You can also turn off the option "show out of stock products" of the configuration in order to do the same since a few months (however it can't do it for the default value)
Please Log in or Create an account to join the conversation.
- expertbeginner
-
Topic Author
- Offline
- Posts: 57
- Thank you received: 2
As Nicolas has said, there is nothing else to do.
When looking for the changes are you looking at a product that has variants with at least one of the variants with a zero (or below) stock level?
To test it, choose a product that has variants, set one or more of the variants to zero stock and then look at the product on the front end. The items that you have set to zero stock should not show in the drop-down. Put the stock level of the items you set to zero back to their correct level, then look at the item on the front end. They should now appear in the drop-down.
Hope that helps.
Please Log in or Create an account to join the conversation.
- Posts: 165
- Thank you received: 3
Do you have any idea how to get this to work in the current version of hikashop?
I did try the method you suggest as well where when a product is out of stock it does not show, but as you said the default value still shows and I need it not to show as well if the product quantity is set to zero. Any Ideas?
Thanks,
Josh
Please Log in or Create an account to join the conversation.
Next version of HikaShop won't show the default variant if it's out of stock and that the "display out of stock products" option is turned off.
Please Log in or Create an account to join the conversation.
- Posts: 165
- Thank you received: 3
Thanks,
Josh
Please Log in or Create an account to join the conversation.
Please Log in or Create an account to join the conversation.