Product Attribute Control Type TextBox

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
14 years ago
I am loving nopCommerce and finding most features easy enough to use.  One feature I require for my products is attributes with control type Text so that I can have the customer enter custom text.  Imagine products that are personalized and I want to collect a name to put on each product.

Any plans to support this control type in the future?

To add it on my own do I need to do more than updating:
AttributeControlTypeEnum and
ProductAttributes.ascx.cs
14 years ago
This option is already implemented. Go to product variant details and look at "Requires text option" and "Text prompt" fields.
14 years ago
What if we want to add another type of control like say a panel or a third part control?

I have been struggling with this and the only references I can find are,

ProductControlTypeEnum.cs &
ProductAttributes.ascx.cs

To test I added a "Panel" reference in ...Enum.cs and then added that control to the collection in ...Atributes.ascx.cs using the same code as TextBox but changing for Panel control.  Only the text label for the Panel control would render.

Nothing else.  Any ideas?  I am pulling my hair out on this.

Thanks.
joe
14 years ago
Multiple textbox options are allowed in nopCommerce 1.40

1. Create required product attributes (Admin area > Attributes > Product Attributes)
2. Go to product varriant details page, then "Product Variant Attributes" tab
3. Add your attributes with "Textbox" control type
14 years ago
Thanks for your response, Andrei.

I understand this and it's a good feature.  But let me be more specific.  

I am looking to add a color swatch type control where the user would click on a colored box to select their color.  A simple way would seem to be a panel control, where the panel could have the attribute name ('Color').  A product-variant-attribute of 'Panel' would render the actual panel control and then the individual 'attribute values' would create (foreach) nested panels that could be bound to the text/name value of the attribute  and converted into RGB background values (ColorTranslator).  Since panels get rendered as divs, nested divs seem the way to go.

Another method would be to use a third party control like RadColorPicker which would be the product-variant-attribute-ControlType and then each ColorPickerItem would be the text value/name of the attribute.

The problem is that I can't get any type of control to render. Only the text/name of the control.  Here is some code.
namespace NopSolutions.NopCommerce.BusinessLogic.Products.Attributes
{
    public enum AttributeControlTypeEnum : int
    {
        /// <summary>
        /// Dropdown list
        /// </summary>
        DropdownList = 1,
        /// <summary>
        /// Radio list
        /// </summary>
        RadioList = 2,
        /// <summary>
        /// Checkboxes
        /// </summary>
        Checkboxes = 3,
        /// <summary>
        /// TextBox
        /// </summary>
        TextBox = 4,
        /// <summary>
        /// ***Add ColorSwatch Control
        /// </summary>
        ColorSwatch = 5,
    }/code]

Then define the 'ColorSwatch' control.  I copied the code from Text Control and ignored the pricing and attribute List code just to try to get any control to render.  The control text will render in the <span> element but not the control itself.
I also tried adding a CssClass to the control and then defining a simple 25x25 box background-black, but still nothing.

Here is the code from ProductAttributes.ascx.cs
[code]case AttributeControlTypeEnum.TextBox:
                                {
                                    TextBox txtAttribute = new TextBox();
                                    txtAttribute.ID = attribute.ProductAttribute.Name;
                                    divAttribute.Controls.Add(txtAttribute);
                                }
                                break;
///***Add and define custom control 'ColorSwatch' as panel
                            case AttributeControlTypeEnum.ColorSwatch:
                                {
                                    Panel pnlAttribute = new Panel();
                                    pnlAttribute.ID = attribute.ProductAttribute.Name;
                                    divAttribute.Controls.Add(pnlAttribute);
                                }
                                break;
                            default:
                                break;
                        }
                        phAttributes.Controls.Add(divAttribute);


Is there another file that I am missing?  Thanks for taking the time to look at this Andrei.  Great product!

joe
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.