Out of Stock / Unpublished Stock Levels

  • Posts: 57
  • Thank you received: 2
12 years 5 months ago #55147

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.

Attachments:

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
12 years 5 months ago #55199

That's really great !
Thank you for sharing your override.

Please Log in or Create an account to join the conversation.

  • Posts: 26
  • Thank you received: 0
12 years 4 months ago #58281

Cannot download the file??

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
12 years 4 months ago #58336

It seems that the file has been corrupted.

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.

  • Posts: 57
  • Thank you received: 2
12 years 4 months ago #58360

Hi,

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.

Attachments:
The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

  • Posts: 26
  • Thank you received: 0
12 years 4 months ago #58365

Thank you expertbeginner

Please Log in or Create an account to join the conversation.

  • Posts: 267
  • Thank you received: 5
12 years 1 month ago #72295

Hello expertbeginner,

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.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
12 years 4 weeks ago #72485

That's all there is to do.
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.

  • Posts: 57
  • Thank you received: 2
12 years 4 weeks ago #72517

HI,
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
10 years 9 months ago #142728

Hi this no longer seems to work with hikashop 2.2.3 I put the override directly in the the "html" folder in my template override and it shows out of stock no matter what you set the stock levels at and it completely removes the variants dropdown.

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

Last edit: 10 years 9 months ago by jschroeder.

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
10 years 9 months ago #142976

Hi,

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
10 years 9 months ago #142979

Hi when is the next version coming out because I have a site i have to launch in like 1.5 weeks that needs this?

Thanks,

Josh

Please Log in or Create an account to join the conversation.

  • Posts: 82868
  • Thank you received: 13376
  • MODERATOR
10 years 9 months ago #143007

Next week.

Please Log in or Create an account to join the conversation.

Time to create page: 0.099 seconds
Powered by Kunena Forum