x items in stock view with Option Variant Quantity

  • Posts: 84
  • Thank you received: 1
  • Hikashop Business
3 days 18 hours 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: 72729
  • Thank you received: 11084
  • MODERATOR
3 days 11 hours 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: 84
  • Thank you received: 1
  • Hikashop Business
3 days 6 hours 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.

Time to create page: 0.059 seconds
Powered by Kunena Forum