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 <noreply@anthropic.com>
This commit is contained in:
parent
8fd0ccb8da
commit
41cf2820f6
1 changed files with 9 additions and 4 deletions
|
|
@ -381,6 +381,8 @@ try {
|
||||||
}
|
}
|
||||||
required = structKeyExists(tmpl, "required") && tmpl.required == true;
|
required = structKeyExists(tmpl, "required") && tmpl.required == true;
|
||||||
options = structKeyExists(tmpl, "options") && isArray(tmpl.options) ? tmpl.options : [];
|
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
|
// Debug: Log options info
|
||||||
response.steps.append("Template '" & tmplName & "' has " & arrayLen(options) & " options (type: " & (isArray(options) ? "array" : "other") & ")");
|
response.steps.append("Template '" & tmplName & "' has " & arrayLen(options) & " options (type: " & (isArray(options) ? "array" : "other") & ")");
|
||||||
|
|
@ -405,12 +407,13 @@ try {
|
||||||
IsActive, RequiresChildSelection, MaxNumSelectionReq,
|
IsActive, RequiresChildSelection, MaxNumSelectionReq,
|
||||||
SortOrder
|
SortOrder
|
||||||
) VALUES (
|
) VALUES (
|
||||||
:bizID, :name, 0, 0, 0, 1, :required, 1, 0
|
:bizID, :name, 0, 0, 0, 1, :required, :maxSel, 0
|
||||||
)
|
)
|
||||||
", {
|
", {
|
||||||
bizID: businessId,
|
bizID: businessId,
|
||||||
name: tmplName,
|
name: tmplName,
|
||||||
required: required ? 1 : 0
|
required: required ? 1 : 0,
|
||||||
|
maxSel: maxSel
|
||||||
}, { datasource: "payfrit" });
|
}, { datasource: "payfrit" });
|
||||||
|
|
||||||
qNewTmpl = queryTimed("SELECT LAST_INSERT_ID() as id", {}, { datasource: "payfrit" });
|
qNewTmpl = queryTimed("SELECT LAST_INSERT_ID() as id", {}, { datasource: "payfrit" });
|
||||||
|
|
@ -432,6 +435,7 @@ try {
|
||||||
|
|
||||||
optName = opt.name;
|
optName = opt.name;
|
||||||
optPrice = structKeyExists(opt, "price") && isSimpleValue(opt.price) ? val(opt.price) : 0;
|
optPrice = structKeyExists(opt, "price") && isSimpleValue(opt.price) ? val(opt.price) : 0;
|
||||||
|
optSelected = structKeyExists(opt, "selected") && opt.selected == true ? 1 : 0;
|
||||||
|
|
||||||
qOpt = queryTimed("
|
qOpt = queryTimed("
|
||||||
SELECT ID FROM Items
|
SELECT ID FROM Items
|
||||||
|
|
@ -442,15 +446,16 @@ try {
|
||||||
queryTimed("
|
queryTimed("
|
||||||
INSERT INTO Items (
|
INSERT INTO Items (
|
||||||
BusinessID, Name, ParentItemID, CategoryID,
|
BusinessID, Name, ParentItemID, CategoryID,
|
||||||
Price, IsActive, SortOrder
|
Price, IsActive, IsCheckedByDefault, SortOrder
|
||||||
) VALUES (
|
) VALUES (
|
||||||
:bizID, :name, :parentID, 0, :price, 1, :sortOrder
|
:bizID, :name, :parentID, 0, :price, 1, :checked, :sortOrder
|
||||||
)
|
)
|
||||||
", {
|
", {
|
||||||
bizID: businessId,
|
bizID: businessId,
|
||||||
name: optName,
|
name: optName,
|
||||||
parentID: templateItemID,
|
parentID: templateItemID,
|
||||||
price: optPrice,
|
price: optPrice,
|
||||||
|
checked: optSelected,
|
||||||
sortOrder: optionOrder
|
sortOrder: optionOrder
|
||||||
}, { datasource: "payfrit" });
|
}, { datasource: "payfrit" });
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in a new issue