Page 1 of 1

Default selection in the product options

Posted: Fri May 29, 2009 2:21 pm
by Willisski
We need default selection in the product options (Color,Size,etc...) Right now the customer has to click on a blank field. it would be great if there was a default for those selections.

Re: Default selection in the product options

Posted: Fri Apr 30, 2010 2:54 pm
by crazyjoe
I can't believe there aren't a million other people thinking this is necessary too! I agree 100% this needs to be implemented in the next release.

Re: Default selection in the product options

Posted: Sat Sep 17, 2011 1:45 pm
by 8bitbyte
Please have a look at this solution for setting the default product option:
http://8bitbyte.com/programming-help/20 ... ct-option/

Re: Default selection in the product options

Posted: Mon Sep 19, 2011 7:17 am
by jmestep
You don't really need javascript to do it. In the App_Code/ProductHelper.cs, you can remove this line:
aspOptions.Items.Add(option.HeaderText);
or this line
aspOptions.Items.Add(String.Empty);
depending on what build of Able you are using. Able had said in the past that it might cause a problem if you are using inventory on the variants, but I don't know if that even applies now, it was so long ago.

Re: Default selection in the product options

Posted: Fri Feb 22, 2013 2:13 pm
by sfeher
Curious if anyone has tested in this GOLD yet....
I'm trying to enforce the first option to be the 'default' choice....

Re: Default selection in the product options

Posted: Tue Feb 26, 2013 4:24 pm
by david-ebt
In GOLD there is a function in the BuyProductDialog.ascx.cs that builds the options choice - GetOptionChoices. By default this function adds the option header text as the first item. We commented out that code to always default to the first option.

Code: Select all

protected List<OptionChoiceItem> GetOptionChoices(Object objOption, int index)
{
	ProductOption productOption = objOption as ProductOption;
	if (productOption == null)
		return GetOptionChoiceValues(new List<OptionChoice>());

	IList<OptionChoice> availableChoices;

	if (!ShowAllOptions && index < ProductVariant.MAXIMUM_ATTRIBUTES)
	{
		availableChoices = OptionChoiceDataSource.GetAvailableChoices(_Product.Id, productOption.OptionId, _SelectedOptionChoices);
	}
	else
	{
		availableChoices = productOption.Option.Choices;
	}

	//OptionChoice optionChoice = new OptionChoice();
	//optionChoice.Name = productOption.Option.HeaderText;
	//optionChoice.OptionId = productOption.OptionId;
	//availableChoices.Insert(0, optionChoice);

	return GetOptionChoiceValues(availableChoices);
}

Re: Default selection in the product options

Posted: Wed Feb 27, 2013 8:12 am
by sfeher
Yes, David......

I found that same code and updated just a few days ago...
Thanks for the response, though!

Re: Default selection in the product options

Posted: Tue Nov 04, 2014 3:13 pm
by meer2005
In R9, I just commented out the following line on the BuyProductDialog:

Code: Select all

 //ddl.Items.Add(new ListItem(opt.HeaderText, string.Empty));
Has anyone done this to where it adds the header text if entered within a products options, or defaults to the first option if there is no header text for that product option?

Re: Default selection in the product options

Posted: Wed Nov 05, 2014 3:41 pm
by Katie
If you are using Gold R9, then you can either use the Header text or you can select a default option. From the Manage Option Choices page, there is a column where you can check a box for "Selected". This will be the default option choice, if you want to use the feature, or it will just default to the header text. No customization necessary!