This repository has been archived on 2026-03-21. You can view files and clone it, but cannot push or open issues or pull requests.
payfrit-biz/api/businesses/saveOrderTypes.cfm
John Mizerek 6cdbff129f Add takeaway/pickup order support
- getOrCreateCart: only require ServicePointID for dine-in (OrderTypeID=1)
- get.cfm + items.cfm: return OrderTypes from Businesses table
- saveOrderTypes.cfm: new endpoint to save business order type config
- KDS: add PICKUP/DELIVERY badges on order cards
- Portal: add Order Types toggle card in settings (Dine-In always on, Takeaway toggle)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-08 10:45:06 -07:00

51 lines
1.5 KiB
Text

<cfsetting showdebugoutput="false">
<cfsetting enablecfoutputonly="true">
<cfcontent type="application/json; charset=utf-8" reset="true">
<cfheader name="Cache-Control" value="no-store">
<cfscript>
/**
* Save Business Order Types
* POST JSON: { "BusinessID": 37, "OrderTypes": "1,2" }
* OrderTypes is a comma-separated list: 1=Dine-In, 2=Takeaway, 3=Delivery
*/
response = { "OK": false };
try {
requestBody = toString(getHttpRequestData().content);
if (!len(requestBody)) {
throw(message="No request body provided");
}
data = deserializeJSON(requestBody);
businessId = structKeyExists(data, "BusinessID") ? val(data.BusinessID) : 0;
if (businessId == 0) {
throw(message="BusinessID is required");
}
orderTypes = structKeyExists(data, "OrderTypes") && isSimpleValue(data.OrderTypes) ? trim(data.OrderTypes) : "1";
// Validate: only allow digits 1-3 separated by commas
if (!reFind("^[1-3](,[1-3])*$", orderTypes)) {
throw(message="OrderTypes must be a comma-separated list of 1, 2, or 3");
}
queryTimed("
UPDATE Businesses SET OrderTypes = :orderTypes
WHERE ID = :bizId
", {
orderTypes: { value: orderTypes, cfsqltype: "cf_sql_varchar" },
bizId: { value: businessId, cfsqltype: "cf_sql_integer" }
}, { datasource: "payfrit" });
response.OK = true;
response.OrderTypes = orderTypes;
} catch (any e) {
response.ERROR = e.message;
}
writeOutput(serializeJSON(response));
</cfscript>