AI OnAI Off
In terms of your first question, though the UI you cannot set fields you create to read only, but if you create them via code you can, by setting it to read only when you create the metafield, for example:
var metaField = new MetaField(fieldName, friendlyName)
{
Owner = MetaClassManagerEditScope.Current.Owner,
AccessLevel = MetaClassManagerEditScope.Current.AccessLevel,
TypeName = fieldType,
IsNullable = allowNulls,
ReadOnly = true
};
You could create a startup method that checks if metafields exist, if they don't create them and make sure they're readonly
Hi,
I have two related questions regarding Commerce Extended Properties.
1 - First question - I have fields in Commerce Extended Properties that go under MetaClass PurchaseOrder and want to make it readonly and hide it in edit mode. Is there any example code or settings?
There are a couple of examples related to Block or Page properties to hide in the edit mode in CMS using EditorDescriptor and few other ways but did not see anything for Commerce Extended Properties.
Properties appear in Order Details - Summary at the bottom section and are marked the properties in red.
Order Management
Order Details - Summary
2 - Second question - Similarly, I would like to hide properties under MetaClass OtherPayment and want to make it hide and readonly in edit mode. Is there any example code or settings?
Properties appear in Order Details - Form Details - and click on the Add Payment button under the Transactions section and a popup modal appears as shown in the figure below.
Order Details - Form Details - Add Payment