Hide Product Option if zero stock

  • Posts: 303
  • Thank you received: 18
7 years 3 hours ago #291619

-- url of the page with the problem -- : www.testing.mojooutdoors.com/spinning-wi...ys/mojo-king-mallard
-- HikaShop version -- : 3.3.6
-- Joomla version -- : 3.8.5

On our test site, i have all product stock set to zero, except for the single product at this link: www.testing.mojooutdoors.com/spinning-wi...ys/mojo-king-mallard

Likewise, the product options also have zero stock, but I can still set them to "yes" for adding it to the main product. However, once you click add to cart, it display "cannot add product to cart." Is there anyway to hide the product option if there is zero stock for the product corresponding to that option? For example, how would i hide the "6-Volt Battery Charger" product option if it has zero stock?

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

  • Posts: 83603
  • Thank you received: 13533
  • MODERATOR
6 years 11 months ago #291668

Hi,

This was added with HikaShop 3.4.0:

We now do not display out of stock variants in the option dropdowns since they can't be bought anyways even if the "display out of stock" setting is activated in the configuration page.

www.hikashop.com/support/documentation/5...ashop-changelog.html

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

  • Posts: 303
  • Thank you received: 18
6 years 11 months ago #291706

I have 3.4.0 installed, but the options still show no/yes even though the product options are out of stock.

Really just need it to say "out of stock" or even hide them completely if the product option is out of stock.

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

  • Posts: 83603
  • Thank you received: 13533
  • MODERATOR
6 years 11 months ago #291731

Hi,

Did you turn off the "Display out of stock products" setting in the HikaShop configuration ?

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

  • Posts: 303
  • Thank you received: 18
6 years 11 months ago #291785

We have products that need to show in the products listing, even if zero stock. Therefore, we cannot turn that off.

Is there anyway to just hide it on the product options page? Or better yet, change the options in the dropdown from "yes/no" to "out of stock" if quantity=0 for that particular product option?

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

  • Posts: 83603
  • Thank you received: 13533
  • MODERATOR
6 years 11 months ago #291807

Hi,

Change the line:

if(!$optionElement->product_published || (!$this->config->get('show_out_of_stock',1) && $optionElement->product_quantity==0)) continue;
to:
if(!$optionElement->product_published || empty($optionElement->product_quantity)) continue;
in the file "option" of the view "product" via the menu Display>Views and it will remove the options without stock regardless of that setting.

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

Time to create page: 0.064 seconds
Powered by Kunena Forum