Skip to main content

Type Alias: MarkOptionByBlockNameAndOptionCode

MarkOptionByBlockNameAndOptionCode = (blockName, optionCodeOrInputValue, skipHistory?) => void

Function

Selects an option using human-readable block name and option code, or sets a value for special widgets.

This convenience function allows for selecting options using their business identifiers rather than internal IDs. It's particularly useful for integrations and automated configurations where human-readable references are preferred over technical identifiers.

For standard option blocks, this method finds the option by its code and selects it. For special widget types (slider, text, number, color, etc.), the second parameter is interpreted as the input value rather than an option code.

Supported Widget Types​

Widget TypeSecond ParameterDescription
Standard (dropdown, swatch, etc.)optionCodeThe code of the option to select
SliderinputValueNumeric value within the slider's range
TextinputValueText string value
NumberinputValueNumeric value
ColorcolorValueHex color value (e.g., "#FF0000")

For more complex widgets (image, print on demand, engrave) or full control, use markOption directly. See the Programmatic Configuration Control guide.

Parameters​

blockName​

string

The display name of the block containing the option

optionCodeOrInputValue​

string | number

The option code for standard widgets, or the input value for special widgets (slider, text, number, color)

skipHistory?​

boolean

If true, does not add this selection to configuration history

Returns​

void

Promise that resolves when the selection is complete

Examples​

// Select a standard option by code
await markOptionByBlockNameAndOptionCode("TableTop", "FINISH-OAK");
// Set a slider value
await markOptionByBlockNameAndOptionCode("Width", 150);
// Set a text input value
await markOptionByBlockNameAndOptionCode("CustomLabel", "My Product");
// Set a number input value
await markOptionByBlockNameAndOptionCode("Quantity", "25");
// Set a custom color
await markOptionByBlockNameAndOptionCode("CustomColor", "#3498db");