Restore the editor
Restore the widget values, the current step, and the design from a stored snapshot when a customer returns from the shopping cart. Use the restoration section when the config logic is complex or relies on data from the ajax widget.
-
Pass the stored snapshot to the editor.
Initialize the e-commerce driver with the snapshot in the restore data:
let ecommerce = await driver.init(product, editor, config,{ editorUrl: "https://{your-site-url}/design-editor/" },/* restore data */ { snapshot: "N4I...." },/* quantity */ 1,/* user info*/ { id: "JohnWood" });Alternatively, call
auWizard.restoreEditor():await auWizard.restoreEditor(snapshot); -
Add the
restorationsection to the workflow file.{"restoration": {"widgets": [...],"steps": [...],"vars": {...}}}When this section is present, UI Framework uses
widgets,steps, andvarsfrom it instead of the original values. If you omit any of them, the values come from the original config. -
Refer to snapshot data with
widgetData.Inside the
restorationsection, dynamic expressions can use thewidgetDataobject. It refers to widget data stored in a snapshot instead of the widget itself.For example, a workflow that fills vehicle dropdowns from the server cannot repeat these requests during restoration. Remove the
ajaxwidgets fromrestoration.widgetsand read their values fromwidgetData:{"widgets": [ ... ],"restoration": {"widgets": [{"name": "order","type": "order","params": {"data": {"Year": "{{ widgetData.vehicleYear.selected.optionValue.title }}","Make": "{{ widgetData.vehicleMake.selected.optionValue.title }}","Model": "{{ widgetData.vehicleModel.selected.optionValue.title }}"},"images": "{{ $['editor'].proofImageUrls.map(x=> x[0]) }}","downloadUrls": "{{ $['editor'].hiResUrls }}"}}]}} -
Map widget properties to
widgetData.Widget values in
widgetDatamay use different property names than in the config:Widget Property in config Property in widgetData ajax response response ajax responses responses ajax statusCode status asset-storage-ajax apiResponse apiResponse asset-storage-ajax response response canvas stateId stateId checkbox ._ value color-picker color color color-selector color color data-driven-editor stateId design.designId data-driven-editor userId access.userId datasheet tableService.getData() tableData datasheet columnSchemes columnSchemes design-editor stateId stateId gallery ._ value html $.container.innerHTML html input-text ._ text option ._ selected.optionValue preflight stateId stateId preflight page page static-text text text -
Configure Design Editor for restoration.
Set
productDefinitionto any valid value, for example, a blank 1×1 design: Design Editor replaces it with the saved design. Replace the bulkyeditorConfigwith{"loadConfigFromState": true}to load the config from the saved state file:{"name": "editor","type": "design-editor","params": {"initial": {"productDefinition": {"surfaces": [{"width": 1,"height": 1}]},"editorConfig": {"loadConfigFromState": true}}}}
After these steps, the restored workflow reuses the snapshot data and does not repeat server requests.