Keep default-checked items with Quantity=0 when deselected

For inverted display: when user deselects a default-checked item, keep it
in cart with Quantity=0 instead of deleting. Cart displays "NO X" for these.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John Pinkyfloyd 2026-03-09 09:11:15 -07:00
parent 6ffc77fcaf
commit 029279658d

View file

@ -457,16 +457,27 @@
<cfset attachDefaultChildren(OrderID, qExisting.ID, ItemID)>
<cfset arrayAppend(request.attachDebug, "AFTER attachDefaultChildren call")>
<cfelse>
<!--- Deselecting: mark as deleted --->
<cfset queryTimed(
"
UPDATE OrderLineItems
SET IsDeleted = b'1'
WHERE ID = ?
",
[ { value = qExisting.ID, cfsqltype = "cf_sql_integer" } ],
<!--- Deselecting: check if this is a default-checked item --->
<cfset var qItemCheck = queryTimed(
"SELECT IsCheckedByDefault FROM Items WHERE ID = ? LIMIT 1",
[ { value = ItemID, cfsqltype = "cf_sql_integer" } ],
{ datasource = "payfrit" }
)>
<cfif qItemCheck.recordCount GT 0 AND val(qItemCheck.IsCheckedByDefault) EQ 1>
<!--- Default item: keep with Quantity=0 for "NO X" display --->
<cfset queryTimed(
"UPDATE OrderLineItems SET Quantity = 0 WHERE ID = ?",
[ { value = qExisting.ID, cfsqltype = "cf_sql_integer" } ],
{ datasource = "payfrit" }
)>
<cfelse>
<!--- Normal item: mark as deleted --->
<cfset queryTimed(
"UPDATE OrderLineItems SET IsDeleted = b'1' WHERE ID = ?",
[ { value = qExisting.ID, cfsqltype = "cf_sql_integer" } ],
{ datasource = "payfrit" }
)>
</cfif>
</cfif>
<cfelse>
<!--- Insert new if selecting, otherwise no-op --->