Features: - Multi-menu support with time-based availability - Menu hours validation against business operating hours - Setup wizard now creates Menu records and links categories - New menus.cfm API for menu CRUD operations - Category schedule filtering (day/time based visibility) - Beacon UUID lookup API for customer app - Parent/child business relationships for franchises - Category listing API for menu builder Portal improvements: - Menu builder theming to match admin UI - Brand color picker fix - Header image preview improvements API fixes: - Filter demo/hidden businesses from restaurant list - Improved error handling throughout Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
77 lines
2.3 KiB
Text
77 lines
2.3 KiB
Text
<cfsetting showdebugoutput="false">
|
|
<cfsetting enablecfoutputonly="true">
|
|
|
|
<cffunction name="readJsonBody" access="public" returntype="struct" output="false">
|
|
<cfset var raw = getHttpRequestData().content>
|
|
<cfif isNull(raw) OR len(trim(raw)) EQ 0>
|
|
<cfreturn {}>
|
|
</cfif>
|
|
<cftry>
|
|
<cfset var data = deserializeJSON(raw)>
|
|
<cfif isStruct(data)>
|
|
<cfreturn data>
|
|
<cfelse>
|
|
<cfreturn {}>
|
|
</cfif>
|
|
<cfcatch>
|
|
<cfreturn {}>
|
|
</cfcatch>
|
|
</cftry>
|
|
</cffunction>
|
|
|
|
<cffunction name="apiAbort" access="public" returntype="void" output="true">
|
|
<cfargument name="payload" type="struct" required="true">
|
|
<cfcontent type="application/json; charset=utf-8">
|
|
<cfoutput>#serializeJSON(arguments.payload)#</cfoutput>
|
|
<cfabort>
|
|
</cffunction>
|
|
|
|
<cfset data = readJsonBody()>
|
|
|
|
<cfset OrderID = val(structKeyExists(data, "OrderID") ? data.OrderID : 0)>
|
|
|
|
<cfif OrderID LTE 0>
|
|
<cfset apiAbort({ "OK": false, "ERROR": "missing_params", "MESSAGE": "OrderID is required.", "DETAIL": "" })>
|
|
</cfif>
|
|
|
|
<cftry>
|
|
<!--- Verify order exists and is in cart status (0) --->
|
|
<cfset qOrder = queryExecute(
|
|
"SELECT OrderID, OrderStatusID FROM Orders WHERE OrderID = ? LIMIT 1",
|
|
[{ value = OrderID, cfsqltype = "cf_sql_integer" }],
|
|
{ datasource = "payfrit" }
|
|
)>
|
|
|
|
<cfif qOrder.recordCount EQ 0>
|
|
<cfset apiAbort({ "OK": false, "ERROR": "not_found", "MESSAGE": "Order not found.", "DETAIL": "" })>
|
|
</cfif>
|
|
|
|
<cfif qOrder.OrderStatusID NEQ 0>
|
|
<cfset apiAbort({ "OK": false, "ERROR": "invalid_status", "MESSAGE": "Only cart orders can be abandoned.", "DETAIL": "" })>
|
|
</cfif>
|
|
|
|
<!--- Delete line items --->
|
|
<cfset queryExecute(
|
|
"DELETE FROM OrderLineItems WHERE OrderLineItemOrderID = ?",
|
|
[{ value = OrderID, cfsqltype = "cf_sql_integer" }],
|
|
{ datasource = "payfrit" }
|
|
)>
|
|
|
|
<!--- Mark order with status 7 (Deleted and started new cart) --->
|
|
<cfset queryExecute(
|
|
"UPDATE Orders SET OrderStatusID = 7, OrderLastEditedOn = NOW() WHERE OrderID = ?",
|
|
[{ value = OrderID, cfsqltype = "cf_sql_integer" }],
|
|
{ datasource = "payfrit" }
|
|
)>
|
|
|
|
<cfset apiAbort({ "OK": true, "MESSAGE": "Order abandoned successfully." })>
|
|
|
|
<cfcatch>
|
|
<cfset apiAbort({
|
|
"OK": false,
|
|
"ERROR": "server_error",
|
|
"MESSAGE": "Failed to abandon order: " & cfcatch.message,
|
|
"DETAIL": cfcatch.message
|
|
})>
|
|
</cfcatch>
|
|
</cftry>
|