Show variant stock level (for out of stock) in dropdown

  • Posts: 50
  • Thank you received: 4
  • Hikashop Business
3 years 2 months ago #329824

-- HikaShop version -- : 4.4.0 Business
-- Joomla version -- : 3.9.24
-- PHP version -- : 7.4

Hi,
Is it possible to show the stock level of the variant before it is selected - for example - in the dropdown?
For example, the size XXL is out of stock but the customer won't know this before they have selected it - then are greeted with an out of stock notice - which may cause annoyance.
I know I could just unpublish that variant until I have stock available but I want to keep it active because I will be adding the notify button to the product page - and people might want to know that we can order more, if they request it.

ETA: I've posted this in the wrong forum, sorry. I don't think I can delete it or move it. I meant to post it in Product & Category Display.

Attachments:
Last edit: 3 years 2 months ago by infinityb.

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

  • Posts: 4519
  • Thank you received: 611
  • MODERATOR
3 years 2 months ago #329888

Hello,

So far in HikaShop there are no options to do that unfortunately... But it's always possible but via an override view ( Documentation ).
Now to be clear we can guide you to perform yourself this custom as usual, but this will require advanced knowledge in Html, Php AND HikaShop view.

Awaiting your returns to going more far on this subject.
Regards

Last edit: 3 years 2 months ago by Philip.

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

  • Posts: 50
  • Thank you received: 4
  • Hikashop Business
3 years 2 months ago #329950

Hi,
I have done some work with overrides and have very basic PHP knowledge but couldn't find the part I would need to change to add an extra word(s) in in this scenario. If you could advise what I would I would need to change that would be much appreciated.

Last edit: 3 years 2 months ago by infinityb.

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
3 years 2 months ago #329958

Hi,

With HikaShop 4.4.1, that we've released last week, we've added the support of products with only one characteristic to the dynamic system that you can activate with the "Characteristics dynamic display" setting.
So update your HikaShop, make sure that this setting is configured to "always" and it should work like you want.
If it doesn't, it means that you have an override of show_block_characteristic.php based on an old version of Hikashop.

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

  • Posts: 50
  • Thank you received: 4
  • Hikashop Business
3 years 2 months ago #329980

The 'characteristic dynamic display' option says it will remove the unavailable items from the list, which is not what I want to do.

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
3 years 2 months ago #329984

Hi,

Then there is no solution with the options available.
Either you have the out of stock variants removed from the list, or you have them.
And the stock is always displayed after the selection of the variant.
That's because if you have two characteristics, you can't display the stock until you've selected both dropdowns.
To change that, then you would be left with custom coding as philippe said. In the file show_block_characteristic.php try to add the code:

$value->characteristic_value.= ' ('.$variant->product_quantity.')';
before the code:
if($variant->product_quantity != 0){
This will add the stock of one of the variants for the value in the dropdown.
So it will work fine with one characteristic, but if you have products with more than one characteristic, it will display a quantity that shouldn't be there.

The following user(s) said Thank You: infinityb

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

  • Posts: 50
  • Thank you received: 4
  • Hikashop Business
3 years 1 month ago #330312

Thank you, this sounds like what I want.
However, I've just tried this on my test site and it doesn't show anything extra in the dropdown. I have added variants to the 'Orange sneakers' product and made sizes 5.5 and 6 out of stock.
(Credentials same as in my other topic)

Attachments:

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
3 years 1 month ago #330314

Hi,

It could be because the option "Display out of stock products" is turned off in the HikaShop configuration, or it could be that you've added the modification for another template than the template you're using on your frontend.

Note also that I've said to add the code BEFORE the other code so that it displays for all the variants whether they have stock or not.
You've added it after, which means that it will only display the stock if it's above 0 and won't change anything otherwise.
So based on your screenshot of the variants, only the choice "5" should have a (3) appear next to the 5.

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

  • Posts: 50
  • Thank you received: 4
  • Hikashop Business
3 years 1 month ago #330325

Apologies, I must have misread. I have now moved the code above instead of below.
However, 'Display out of stock products' is switched on, and the override is for Protostar, which is the frontend template I am using. (My original post/screenshots are from my live website which I am not using for testing).
It still doesn't show anything.

Attachments:

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

  • Posts: 50
  • Thank you received: 4
  • Hikashop Business
3 years 1 month ago #330326

When I set 'Display out of stock products' to 'No' it works but obviously I want to see the out of stock products!

Attachments:

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
3 years 1 month ago #330346

Hi,

In the same file, change the line:
if(!$config->get('show_out_of_stock',1)){
to:
if(true){
and it will work regardless of how that option is configured.

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

  • Posts: 50
  • Thank you received: 4
  • Hikashop Business
2 years 11 months ago #332427

Hi, sorry about the delay.
I have made this amendment but the out of stock items are not showing in the drop down.
What I would like to see is:
4.5 (-1)
5 (3)
5.5 (0)
6 (0)
6.5 (-1)

But what I am seeing is
4.5 (-1)
5 (3)
6.5 (-1)

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
2 years 11 months ago #332447

Hi,

Then I'm not sorry. It would require some code debugging to understand what is missing and what should be changed where.
Please understand that this is outside normal user support and getting into custom development work.
If you want us to work on this for you to make sure it displays like you want, please use our contact form to request a quote on this :
www.hikashop.com/support/contact-us.html

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

  • Posts: 50
  • Thank you received: 4
  • Hikashop Business
2 years 11 months ago #332456

This is a feature of many other online shops (examples attached), please consider it a feature request.
You said that the code you provided above would achieve this, which it hasn't. I have implemented it exactly as you have advised.

Attachments:

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
2 years 11 months ago #332474

Hi,

It's noted.

In my first message where I posted some code here I said "try this code". The code I gave here has not been tested. It's just code I think would work knowing the code and what you want to do. But without proper coding there can be things I didn't think about that I would know if I spent an hour or 2 on it. Please understand that I was just trying to help and give you a head start with your modifications of the views. If you understood that I would provide ready-made modifications that were sure to work to do what you want, then I'm sorry as that's not what I wanted to say.

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

Time to create page: 0.063 seconds
Powered by Kunena Forum