Page 1 of 1

Product Variant price in option dropdown

Posted: Wed May 20, 2009 2:22 pm
by jmestep
Is there a way of picking up the price modifier for an option on the product page when the product has variants from the variant price?
The code below to add the modifier doesn't work if the there are variants and the modifier is put in to the box on the Edit variants for the product, but the price has been deleted from the price in the option grid.

Code: Select all

if (optionOption.PriceModifier > 0)
                        {
                            aspOptions.Items.Add(new ListItem(optionOption.Name + " ( +" + optionOption.PriceModifier.ToString("ulc") + ")", optionOption.OptionChoiceId.ToString()));
                        }
                        else if (optionOption.PriceModifier < 0)
                        {
                            aspOptions.Items.Add(new ListItem(optionOption.Name + " (  " + optionOption.PriceModifier.ToString("ulc") + ")", optionOption.OptionChoiceId.ToString()));
                        }
                        else
                           {
 aspOptions.Items.Add(new ListItem(optionOption.Name, optionOption.OptionChoiceId.ToString()));                      
                            }
Or is this something where they should have the prices in the option grid to start with?
Thanks

Re: Product Variant price in option dropdown

Posted: Thu May 21, 2009 5:47 am
by mazhar
You can try to load variant by using ProductVariantDataSource.LoadForOptionList(productId, choice ids)

Re: Product Variant price in option dropdown

Posted: Tue May 26, 2009 5:59 am
by jmestep
This is just in case someone else runs across it. I was having trouble getting the choiceIds and Mazar posted code here that does it:
viewtopic.php?f=42&t=10310