Page 1 of 1

Show Option Price in Option Dropdown

Posted: Sun May 25, 2008 3:38 pm
by jbburgos
Hello All,

I am trying to show the added option price for each option in the option dropdown box, for example:

Product 1

Option 1 (this is the base price so I don't want anything to show up next to it)
Option 2 +30 (this option adds $30 to the base price so I want it to show up next to the option)
Option 3 +50
etc.

I am using variants and the only way I can do the above right now is to include the dollar value in each option name, for example:

When I create the options above I would name them:

Option 1
Option 2 +30
Option 3 +50
etc.

This poses a problem in the future, when those prices change I have to manually change the option names, which also deletes all of the variants. This would be a HUGE waste of time, the whole point of having a database driven cart is so you don't have to do all of the manual work needed for a non database driven cart. If anyone has any idea on how to do the above please let me know :D

I searched through the forums and couldn't find anything related to the above problem.

Thanks!

Justin

Re: Show Option Price in Option Dropdown

Posted: Sun May 25, 2008 5:48 pm
by compunerdy
Use kits instead.

Re: Show Option Price in Option Dropdown

Posted: Tue May 27, 2008 12:05 pm
by m_plugables
Check the App_Code/ProductHelper.cs file's BuildProductOptions method. It may help you.

Re: Show Option Price in Option Dropdown

Posted: Sat May 31, 2008 6:45 pm
by jbburgos
Thanks for the help, I found this in the file you suggested:

// CREATE A DROPDOWN FOR THE OPTIONS
DropDownList aspOptions = new DropDownList();
RequiredFieldValidator aspOptionsValidator = new RequiredFieldValidator();
aspOptions.ID = "option" + i;
if (autoPostBack) aspOptions.AutoPostBack = true;
else


It looks like I can put a price variable inside the "option" for example:

x = option price

aspOptions.ID = "option +x" + i;

Does this look right? Does anyone know what the option price variable is?

Thanks for all your help

Re: Show Option Price in Option Dropdown

Posted: Mon Jun 02, 2008 7:12 am
by m_plugables
I think you need to modify the following code in the Method

Code: Select all

foreach (OptionChoice optionOption in availableOptions)
                    {
                        aspOptions.Items.Add(new ListItem(optionOption.Name, optionOption.OptionChoiceId.ToString()));
                    }
The changes you require may be some thing like the code below

Code: Select all

foreach (OptionChoice optionOption in availableOptions)
                    {
                        aspOptions.Items.Add(new ListItem(optionOption.Name+" - "+optionOption.PriceModifier.ToString("ulc"), optionOption.OptionChoiceId.ToString()));
                    }