You can add options using a script.
Depending of the category type, the options are displayed as a drop-down list or checkboxes in the interface. Usage examples:
// Iterating through availble options for ( const v of Context.fields.category.data.variants) {
console.log(v.name, v. code);
}
// Adding an option to the list of available options const v1 = { name: 'ONE', code: 'one' };
Context.fields.category.data.variants.push(v1);
variants
variants:object
List of acceptable values: key — code, value — object TEnum.
Usage examples:
// Getting the option by its code // If the code contains symbols invalid for the JS identifier, // for example, starts with a digit or contains a hyphen, // specify the code in square brackets const v1 = Context.fields.category.variants['1n'];
const v2 = Context. fields.category.variants['order-type'];
// With a valid identifier, you can use a dot or square brackets const v3 = Context.fields.category.variants. product;
const v4 = Context.fields.category.variants['product'];
// Getting all options as the objects of `TEnum` const dict = Context.fields. category.variants;
const allVariants = Object.keys(dict).map(code => {
const key = code as keyof typeof dict;
return dict[key];
});
Description of a Category type field
Type parameters
T: string
Hierarchy
Properties
Readonly data
Data of the category field.
Type declaration
variants: TEnum<string>[]
Set of available category options for selection.
You can add options using a script. Depending of the category type, the options are displayed as a drop-down list or checkboxes in the interface.
Usage examples:
// Iterating through availble options for ( const v of Context.fields.category.data.variants) { console.log(v.name, v. code); } // Adding an option to the list of available options const v1 = { name: 'ONE', code: 'one' }; Context.fields.category.data.variants.push(v1);variants
List of acceptable values: key —
code, value — object TEnum.Usage examples:
// Getting the option by its code // If the code contains symbols invalid for the JS identifier, // for example, starts with a digit or contains a hyphen, // specify the code in square brackets const v1 = Context.fields.category.variants['1n']; const v2 = Context. fields.category.variants['order-type']; // With a valid identifier, you can use a dot or square brackets const v3 = Context.fields.category.variants. product; const v4 = Context.fields.category.variants['product']; // Getting all options as the objects of `TEnum` const dict = Context.fields. category.variants; const allVariants = Object.keys(dict).map(code => { const key = code as keyof typeof dict; return dict[key]; });Type declaration