Fix Toast menu import for new URL format and prices array
- Add item.prices array support to first code path (was only checking item.price scalar, but Toast now uses prices: [4.50] array) - Extract individual address fields (addressLine1, city, state, zip) from ROOT_QUERY restaurant data for saveWizard compatibility - Update modifier extraction URL detection to match any toasttab.com domain (not just order.toasttab.com) - Update slug-based URL construction to use www.toasttab.com/local/order/ format instead of deprecated order.toasttab.com/online/ format Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
d822fcad5a
commit
4351978c10
1 changed files with 26 additions and 9 deletions
|
|
@ -397,7 +397,9 @@
|
||||||
<cfif structKeyExists(item, "name")>
|
<cfif structKeyExists(item, "name")>
|
||||||
<cfset itemCategoryMap[item.name] = effectiveName>
|
<cfset itemCategoryMap[item.name] = effectiveName>
|
||||||
<!--- Extract price --->
|
<!--- Extract price --->
|
||||||
<cfif structKeyExists(item, "price") AND isNumeric(item.price)>
|
<cfif structKeyExists(item, "prices") AND isArray(item.prices) AND arrayLen(item.prices) GT 0 AND isNumeric(item.prices[1])>
|
||||||
|
<cfset itemPriceMap[item.name] = val(item.prices[1])>
|
||||||
|
<cfelseif structKeyExists(item, "price") AND isNumeric(item.price)>
|
||||||
<cfset itemPriceMap[item.name] = val(item.price)>
|
<cfset itemPriceMap[item.name] = val(item.price)>
|
||||||
<cfelseif structKeyExists(item, "unitPrice") AND isNumeric(item.unitPrice)>
|
<cfelseif structKeyExists(item, "unitPrice") AND isNumeric(item.unitPrice)>
|
||||||
<cfset itemPriceMap[item.name] = val(item.unitPrice)>
|
<cfset itemPriceMap[item.name] = val(item.unitPrice)>
|
||||||
|
|
@ -450,7 +452,9 @@
|
||||||
<cfset itemCategoryMap[item.name] = groupName>
|
<cfset itemCategoryMap[item.name] = groupName>
|
||||||
</cfif>
|
</cfif>
|
||||||
<!--- Extract price - try multiple field names --->
|
<!--- Extract price - try multiple field names --->
|
||||||
<cfif structKeyExists(item, "price") AND isNumeric(item.price)>
|
<cfif structKeyExists(item, "prices") AND isArray(item.prices) AND arrayLen(item.prices) GT 0 AND isNumeric(item.prices[1])>
|
||||||
|
<cfset itemPriceMap[item.name] = val(item.prices[1])>
|
||||||
|
<cfelseif structKeyExists(item, "price") AND isNumeric(item.price)>
|
||||||
<cfset itemPriceMap[item.name] = val(item.price)>
|
<cfset itemPriceMap[item.name] = val(item.price)>
|
||||||
<cfelseif structKeyExists(item, "unitPrice") AND isNumeric(item.unitPrice)>
|
<cfelseif structKeyExists(item, "unitPrice") AND isNumeric(item.unitPrice)>
|
||||||
<cfset itemPriceMap[item.name] = val(item.unitPrice)>
|
<cfset itemPriceMap[item.name] = val(item.unitPrice)>
|
||||||
|
|
@ -1052,11 +1056,24 @@
|
||||||
</cfif>
|
</cfif>
|
||||||
<cfif structKeyExists(restaurant, "location") AND isStruct(restaurant.location)>
|
<cfif structKeyExists(restaurant, "location") AND isStruct(restaurant.location)>
|
||||||
<cfset loc = restaurant.location>
|
<cfset loc = restaurant.location>
|
||||||
<cfif structKeyExists(loc, "address1")>
|
<cfif structKeyExists(loc, "address1") AND NOT isNull(loc.address1)>
|
||||||
|
<cfset toastBusiness["addressLine1"] = loc.address1>
|
||||||
<cfset toastBusiness["address"] = loc.address1>
|
<cfset toastBusiness["address"] = loc.address1>
|
||||||
<cfif structKeyExists(loc, "city") AND NOT isNull(loc.city)><cfset toastBusiness["address"] = toastBusiness.address & ", " & loc.city></cfif>
|
<cfif structKeyExists(loc, "city") AND NOT isNull(loc.city)>
|
||||||
<cfif structKeyExists(loc, "state") AND NOT isNull(loc.state)><cfset toastBusiness["address"] = toastBusiness.address & ", " & loc.state></cfif>
|
<cfset toastBusiness["city"] = loc.city>
|
||||||
<cfif structKeyExists(loc, "zip") AND NOT isNull(loc.zip)><cfset toastBusiness["address"] = toastBusiness.address & " " & loc.zip></cfif>
|
<cfset toastBusiness["address"] = toastBusiness.address & ", " & loc.city>
|
||||||
|
</cfif>
|
||||||
|
<cfif structKeyExists(loc, "state") AND NOT isNull(loc.state)>
|
||||||
|
<cfset toastBusiness["state"] = loc.state>
|
||||||
|
<cfset toastBusiness["address"] = toastBusiness.address & ", " & loc.state>
|
||||||
|
</cfif>
|
||||||
|
<cfif structKeyExists(loc, "zip") AND NOT isNull(loc.zip)>
|
||||||
|
<cfset toastBusiness["zip"] = loc.zip>
|
||||||
|
<cfset toastBusiness["address"] = toastBusiness.address & " " & loc.zip>
|
||||||
|
<cfelseif structKeyExists(loc, "zipCode") AND NOT isNull(loc.zipCode)>
|
||||||
|
<cfset toastBusiness["zip"] = loc.zipCode>
|
||||||
|
<cfset toastBusiness["address"] = toastBusiness.address & " " & loc.zipCode>
|
||||||
|
</cfif>
|
||||||
</cfif>
|
</cfif>
|
||||||
<cfif structKeyExists(loc, "phone") AND NOT isNull(loc.phone)>
|
<cfif structKeyExists(loc, "phone") AND NOT isNull(loc.phone)>
|
||||||
<cfset toastBusiness["phone"] = loc.phone>
|
<cfset toastBusiness["phone"] = loc.phone>
|
||||||
|
|
@ -1307,7 +1324,7 @@
|
||||||
<cftry>
|
<cftry>
|
||||||
<!--- Determine Toast URL for Playwright --->
|
<!--- Determine Toast URL for Playwright --->
|
||||||
<cfset toastUrl = "">
|
<cfset toastUrl = "">
|
||||||
<cfif isDefined("targetUrl") AND reFindNoCase("order\.toasttab\.com", targetUrl)>
|
<cfif isDefined("targetUrl") AND reFindNoCase("toasttab\.com", targetUrl)>
|
||||||
<!--- URL mode: use original URL --->
|
<!--- URL mode: use original URL --->
|
||||||
<cfset toastUrl = targetUrl>
|
<cfset toastUrl = targetUrl>
|
||||||
<cfelse>
|
<cfelse>
|
||||||
|
|
@ -1316,14 +1333,14 @@
|
||||||
<cfset slugMatch = reMatchNoCase('"shortUrl"\s*:\s*"([^"]+)"', pageHtml)>
|
<cfset slugMatch = reMatchNoCase('"shortUrl"\s*:\s*"([^"]+)"', pageHtml)>
|
||||||
<cfif arrayLen(slugMatch)>
|
<cfif arrayLen(slugMatch)>
|
||||||
<cfset slug = reReplaceNoCase(slugMatch[1], '.*"shortUrl"\s*:\s*"([^"]+)".*', '\1')>
|
<cfset slug = reReplaceNoCase(slugMatch[1], '.*"shortUrl"\s*:\s*"([^"]+)".*', '\1')>
|
||||||
<cfset toastUrl = "https://order.toasttab.com/online/" & slug>
|
<cfset toastUrl = "https://www.toasttab.com/local/order/" & slug>
|
||||||
</cfif>
|
</cfif>
|
||||||
<!--- Try gift card URL pattern --->
|
<!--- Try gift card URL pattern --->
|
||||||
<cfif NOT len(toastUrl)>
|
<cfif NOT len(toastUrl)>
|
||||||
<cfset giftMatch = reMatchNoCase('toasttab\.com/([a-zA-Z0-9_-]+)/giftcards', pageHtml)>
|
<cfset giftMatch = reMatchNoCase('toasttab\.com/([a-zA-Z0-9_-]+)/giftcards', pageHtml)>
|
||||||
<cfif arrayLen(giftMatch)>
|
<cfif arrayLen(giftMatch)>
|
||||||
<cfset slug = reReplaceNoCase(giftMatch[1], '.*toasttab\.com/([a-zA-Z0-9_-]+)/giftcards.*', '\1')>
|
<cfset slug = reReplaceNoCase(giftMatch[1], '.*toasttab\.com/([a-zA-Z0-9_-]+)/giftcards.*', '\1')>
|
||||||
<cfset toastUrl = "https://order.toasttab.com/online/" & slug>
|
<cfset toastUrl = "https://www.toasttab.com/local/order/" & slug>
|
||||||
</cfif>
|
</cfif>
|
||||||
</cfif>
|
</cfif>
|
||||||
</cfif>
|
</cfif>
|
||||||
|
|
|
||||||
Reference in a new issue