Product Attribute Hidden Control Type

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
Has anyone ever asked for a product attribute of hidden type?

I have found myself creating a textbox product attribute, and then hiding it via css or some other method in my projects over and over again. But if it was really that simple, i would not be asking for this feature....

It is easy to hide them with css on the product details page, but what about on checkout views, and in message templates, and anywhere else they can show up as well (Order history)...

So what I am thinking is a new type of product attribute for hidden fields.

By default it would present itself as a hidden field on the product details page.
But it would be a text box or label on any admin view or email.
But on any customer / public view or email it would not be visible.

I am currently using it primarily when crating custom product details screens. I need to store more information than I really need to have the end user know about, but it is great to have the individual per order item data for these values.

I currently implement this code in my own plugins for the sites I am working on, but I feel this could be so much easier.  

Would anyone else have a use for this type of control?
4 years ago
I would.  I need a Product attribute that should not be displayed.
This would create a new sku for that product. My employer wants to swap the product with an alternative product based on a discount code being applied to basket.
Having a hidden product attribute would make management of this product so much easier
4 years ago
You can do it but you need to customise and have code setting that deturimes if it is hidden
Then you need to modify _ProductAttributes.cshtml
In simple terms

1. Add in a style variable i.e. styleattr
2. Set it to the normal display value
    <div class="attributes">
        <dl>
            @foreach (var attribute in Model)
            {
                        // code for start date display none
                        var styleattr = "block";

3. Then in code deturime if the atttribute is hidden and change the  display attribute value to
                        styleattr = "none";

4. Then later when you go to build the attribute

            <dt id="@($"product_attribute_label_{attribute.Id}")" style="display:@styleattr">
...
            <dd id="@($"product_attribute_input_{attribute.Id}")" style="display:@styleattr">
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.