From 41cf2820f648e5e8b2ffb668c29533909ba41abb Mon Sep 17 00:00:00 2001 From: John Mizerek Date: Sat, 7 Mar 2026 18:47:32 -0800 Subject: [PATCH] Save modifier type, maxSelections, and default-checked state from WooCommerce - checkbox groups get MaxNumSelectionReq=0 (unlimited), radio/select get 1 - Pre-checked options (e.g. preselected condiments) saved with IsCheckedByDefault=1 Co-Authored-By: Claude Opus 4.6 --- api/setup/saveWizard.cfm | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/api/setup/saveWizard.cfm b/api/setup/saveWizard.cfm index 52b8afb..0351917 100644 --- a/api/setup/saveWizard.cfm +++ b/api/setup/saveWizard.cfm @@ -381,6 +381,8 @@ try { } required = structKeyExists(tmpl, "required") && tmpl.required == true; options = structKeyExists(tmpl, "options") && isArray(tmpl.options) ? tmpl.options : []; + tmplType = structKeyExists(tmpl, "type") && isSimpleValue(tmpl.type) ? tmpl.type : "select"; + maxSel = (tmplType == "checkbox") ? 0 : 1; // Debug: Log options info response.steps.append("Template '" & tmplName & "' has " & arrayLen(options) & " options (type: " & (isArray(options) ? "array" : "other") & ")"); @@ -405,12 +407,13 @@ try { IsActive, RequiresChildSelection, MaxNumSelectionReq, SortOrder ) VALUES ( - :bizID, :name, 0, 0, 0, 1, :required, 1, 0 + :bizID, :name, 0, 0, 0, 1, :required, :maxSel, 0 ) ", { bizID: businessId, name: tmplName, - required: required ? 1 : 0 + required: required ? 1 : 0, + maxSel: maxSel }, { datasource: "payfrit" }); qNewTmpl = queryTimed("SELECT LAST_INSERT_ID() as id", {}, { datasource: "payfrit" }); @@ -432,6 +435,7 @@ try { optName = opt.name; optPrice = structKeyExists(opt, "price") && isSimpleValue(opt.price) ? val(opt.price) : 0; + optSelected = structKeyExists(opt, "selected") && opt.selected == true ? 1 : 0; qOpt = queryTimed(" SELECT ID FROM Items @@ -442,15 +446,16 @@ try { queryTimed(" INSERT INTO Items ( BusinessID, Name, ParentItemID, CategoryID, - Price, IsActive, SortOrder + Price, IsActive, IsCheckedByDefault, SortOrder ) VALUES ( - :bizID, :name, :parentID, 0, :price, 1, :sortOrder + :bizID, :name, :parentID, 0, :price, 1, :checked, :sortOrder ) ", { bizID: businessId, name: optName, parentID: templateItemID, price: optPrice, + checked: optSelected, sortOrder: optionOrder }, { datasource: "payfrit" }); }