how to show 'none' as default for product option?

  • Posts: 26
  • Thank you received: 0
10 years 3 months ago #137923

Hi,

Just purchased a Business edition in order to use Product Options and just can't figure it out. I have spent a requisite half-hour searching through this forum but could not find the answer.

We have many products on our site - example: emotorwerks.com/products/online-store/pr...-ev-charging-station . We need to add another product ( emotorwerks.com/products/online-store/pr...s/related_product-44 ) as option. However, when I do that, my main product page does not allow me to order a product without an option - i.e. without cables. I thought that's the whole point of options - people can decide to order another product as an option in addition to main product or they can decide to add none of the options. The current config seems to be forcing people to add one of the variants of the 'optional' product which is not the intent at all...

I know that the way to hack it would be to create a variant 'none' in the optional product and default to that but then that product page would open on 'none' itself - bad user experience.

Stuck. Pls help.

thanks,
Valery

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

  • Posts: 81504
  • Thank you received: 13063
  • MODERATOR
10 years 3 months ago #137959

Hi,

That is indeed what I would have recommended. If you want to also sell the option as its own product and that you don't want the "none" variant there, then you would need two separate product. One for the option with that "none" value and one without it so that you can sell it on its own without that choice. Simply add the one with the "none" value to an unpublished category so that it is not purchasable on its own.

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

  • Posts: 26
  • Thank you received: 0
10 years 3 months ago #138023

Thanks. So I have to duplicate all the product info for the option product twice?? But this is such a hack, no?

I am sure that what we are trying to do is actually the normal use case for options. That's the whole point of optional additions, no? Please consider this for one of your next releases.

Valery

Last edit: 10 years 3 months ago by valerun.

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

  • Posts: 81504
  • Thank you received: 13063
  • MODERATOR
10 years 3 months ago #138030

It's not the whole point no. Most of the times, options are only options and aren't sold separately and when they are, most of the time they don't have characteristics. So your case is not common.

You sure can do it automatically with a small code modification by editing the file "option" of the view "product" via Display>Views and changing the line:

$this->values = array();
to:
$this->values = array(JHTML::_('select.option', 0,JText::_('HIKASHOP_NO')));
and removing the line:
$value = $variant->product_id;

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

  • Posts: 26
  • Thank you received: 0
10 years 3 months ago #138037

Thanks Nicholas for code snippet - I will try it. Will it stay when we upgrade to next version of Hikashop?

And re our case not being common - this is how every good store that allows to configure hardware products operates. For example, see store.apple.com/us/buy-mac/macbook-pro?p...E865LL/A&step=config . Dell, Lenovo, Samsung, etc. Wherever you need to configure your product with options, you need an ability to select 'none' for that second hard drive, or an add-on printer, etc.

Last edit: 10 years 3 months ago by valerun.

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

  • Posts: 26
  • Thank you received: 0
10 years 3 months ago #138041

maybe I just don't understand how to use 'options' functionality in Hikashop and am missing something obvious? For example, from your explanation I can't understand how I would implement any of the options shown on my example at store.apple.com/us/buy-mac/macbook-pro?p...E865LL/A&step=config . Even for the options without 'none' selection, the default option does not carry any incremental price increase. This seems impossible to create using Hikashop options, no? unless, of course, I set up that variant of an option product with zero price - which brings the issue I mentioned with a standalone display of such product...

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

  • Posts: 26
  • Thank you received: 0
10 years 3 months ago #138046

from the options file:
----
if(empty($optionElement->variants)){
if(!$optionElement->product_published || (!$this->config->get('show_out_of_stock',1) && $optionElement->product_quantity==0)) continue;
$this->values[] = JHTML::_('select.option', 0,JText::_('HIKASHOP_NO'));


does this mean that I would have had a 'none' option if my option product did not have characteristics / variants??

Last edit: 10 years 3 months ago by valerun.

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

  • Posts: 81504
  • Thank you received: 13063
  • MODERATOR
10 years 3 months ago #138114

Hi,

1. You won't loose your changes to that view file when you upgrade.

2. You name apple, but apple doesn't sell RAM and processor alone. They only sell the computer with the options, so you can do that with HikaShop options with characteristics and a none variant without the issue you mention of the none variant appearing on the product page of the option product on standalone since they don't sell it in standalone.
I'm not saying that options are not common, just that your needs are a bit specific compared to most shops.

3. Yes, if you don't have characteristics in a product that you use as an option, HikaShop automatically adds a "no" choice to the dropdown because of course there is no point in having an option dropdown where you only have one choice.

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

  • Posts: 11
  • Thank you received: 0
4 years 4 months ago #314030

Hello Nicolas,

Does the code presented in this thread still count for Hikashop Business v 4.2.2?

You sure can do it automatically with a small code modification by editing the file "option" of the view "product" via Display>Views and changing the line:

$this->values = array();
to:
$this->values = array(JHTML::_('select.option', 0,JText::_('HIKASHOP_NO')));
and removing the line:
$value = $variant->product_id;


With regards,
Webdexter

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

  • Posts: 81504
  • Thank you received: 13063
  • MODERATOR
4 years 4 months ago #314031

Hi,

You actually don't need to change any code anymore.
You can add an entry with the namekey add_no_to_options and the value 1 in the table hikashop_config via your phpmyadmin to add the No value to the option dropdowns.
And you can add an entry with the namekey select_option_default_value and the value 0 in the table hikashop_config via your phpmyadmin if you want that "No" value to be selected by default.
It's better than having view overrides as you will still get the improvements and fixes we'll add in the future to the product / option.php view file.

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

  • Posts: 37
  • Thank you received: 3
4 years 4 days ago #317537

Tried this, but I keep on getting errors. Would be nice if there is a small explanation about this OR it will be added as an option.

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

  • Posts: 81504
  • Thank you received: 13063
  • MODERATOR
4 years 4 days ago #317543

Hi,

What did you try ? As I said in my last message here, no code modification is necessary anymore. You can just add the entries in the hikashop_config table.
If you get errors, then please explain precisely what you did and provide a link to a product page with the issue as well as the error messages you got so that we can better understand your situation in order to help you.

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

  • Posts: 37
  • Thank you received: 3
4 years 3 days ago #317573

Nevermind, I got it. Seams the MYSQL command worked but an error showed up. When checking it again it IS working! (screenshot stated it was allready added... )

Attachments:
Last edit: 4 years 3 days ago by Robby.

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

Time to create page: 0.107 seconds
Powered by Kunena Forum