x items in stock view with Option Variant Quantity

  • Posts: 135
  • Thank you received: 5
2 years 11 months ago #332273

-- HikaShop version -- : 4.4.2
-- Joomla version -- : 3.9.26
-- PHP version -- : 7.3.27
-- Browser(s) name and version -- : Version 1.23.75 Chromium: 90.0.4430.93 (Official Build) (64-bit)
-- Error-message(debug-mod must be tuned on) -- : No Error Message.

How do I make the option variant Quantity show instead of the Main Product QTY?

If I set the main product to unlimited and the option variant to say 190, how does that work?

I am unable to find anything about that.
Currently if the main product is set to "unlimited" and the option variant is 190, it shows nothing in the "x items in stock" next to the add cart button. In the attached image the "Clear Glass" option has a variant value of 190.
If I select an option nothing changes.
If I set the main product qty to 1, it says 1 item in stock, then if I select an option, it still says "1 item in stock where it should say 190 items in stock" taken from the option variant selected.

Any help would be appreciated, my work around would be to setup 3 products and no use the variant in the options.

Regards,
Mark

Attachments:

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

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

Hi,

The stock next to the quantity input field is the quantity of the main product.
Options can have their own stock, but it's not displayed there.
Usually, the stock of options is unlimited (like when you have options for pizza toppings or hardware options for computers)
If you want to display the quantity of each choice of an option, usually, that's done inside the dropdown selector via an override of the view file product / option.php via the menu Display>Views.
For example, this line there is to add the price of each variant of the option product:

$text .= ' ( '.($positive?'+ ':'').$this->currencyHelper->format($price, $ok->price_currency_id).' )';
So you could add a similar line for the stock:
$text .= ' '.$variant->product_quantity;
Now, to swap the stock displayed next to the input field based on the option selected is more complex. It would require some javascript custom code to update the displayed quantity based on what is selected. It's not impossible, but it requires proper development work.

The following user(s) said Thank You: markfell

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

  • Posts: 135
  • Thank you received: 5
2 years 11 months ago #332293

Thank Nicolas,
Great resource and knowledgeable as ever.
I will just go and use 3 separate products as it will be way too hard to develop as you say.
Thank you for the feedback.

Mark

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

  • Posts: 292
  • Thank you received: 5
  • Hikashop Business
2 years 8 months ago #334915

Nicolas mentioned It's not impossible, but it requires proper development work.
No mention if this is planned for the future / on todo list - is it?

Not only the display to change - would not want the customer to be able to enter more than the option stock.
If multiple options selectable only the lowest option quantity of those selected available to order.

You are already changing the price displayed, shame not changing the quantity available at the same time.

Last edit: 2 years 8 months ago by brainforge.

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

  • Posts: 81539
  • Thank you received: 13069
  • MODERATOR
2 years 8 months ago #334916

Hi,

Well, usually, merchants contacting us about options and quantity were fine with having the quantity of the variant displayed next to the price of the option.
Having the quantity of the main product taking into account the option selected dynamically on the page is possible but so far no one raised the idea as something really necessary. So one it's not on the todo list.
It wouldn't be that complex to do in the product / option.php view file. Basically, you just have to add a data attribute with the quantity of each variant and some javascript to update the text of the stock and the data attribute of the quantity input field.
I suppose it's a few hours of coding and testing. We could add it in the todo list, but I would say we have more important things to implement so it's not really a priority.

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

Time to create page: 0.072 seconds
Powered by Kunena Forum