Hi,
I am using a color picker for an ecommerce site. I am using it as a color swatch for the user to select the color of shirt they want. Everything is working as expected with one exception. I need to find a way to add another argument to the ColorPickerItem in addition to the value and title.
The logic works like this. The admin adds an attribute such as 'color' to the product. The attribute is assigned a control (ColorPicker). The admin then adds values to the control (Red, Blue, White, etc.). The ecommerce site logic usually works with a dropdown control which also has only 2 arguments (value, text). The value is the database value of the 'attribute-value' (Red-id, Blue-id, etc.). How can I add another argument to RadColorPicker such as RadColorPicker(int Id, Color value, String title).
Here is some code: Hope this makes sense.
///***Add ColorSwatch Control |
case AttributeControlTypeEnum.ColorSwatch: |
{ |
///***Define RadColorPicker Attributes |
RadColorPicker rcpColorSwatch = new RadColorPicker(); |
rcpColorSwatch.ID = attribute.ProductAttribute.Name; |
rcpColorSwatch.Preset = ColorPreset.None; |
rcpColorSwatch.ShowEmptyColor = false; |
rcpColorSwatch.PreviewColor = false; |
///***Add Attribute Collection Values to ColorPickerItemCollection |
ProductVariantAttributeValueCollection pvaValues = attribute.ProductVariantAttributeValues; |
foreach (ProductVariantAttributeValue pvaValue in pvaValues) |
{ |
string pvaValuepvaValueName = pvaValue.Name; |
decimal priceAdjustmentBase = TaxManager.GetPrice(productVariant, pvaValue.PriceAdjustment); |
decimal priceAdjustment = CurrencyManager.ConvertCurrency(priceAdjustmentBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); |
if (priceAdjustmentBase > decimal.Zero) |
pvaValueName += string.Format(" [+{0}]", PriceHelper.FormatPrice(priceAdjustment, false, false)); |
ColorPickerItem cpiValueItem = new ColorPickerItem((ColorTranslator.FromHtml(pvaValue.ProductVariantAttributeValueID.ToString())), (pvaValueName)); |
rcpColorSwatch.Items.Add(cpiValueItem); ///Above-This is the ValueId of color. I need this plus the color value |
} |
divAttribute.Controls.Add(rcpColorSwatch); |
} |
break; |