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;
|
||||
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" });
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue