If you copy the component from my template and paste it into your template, it should be exactly the same. As for the JSON, the easiest would be to replace your variable names with the ones I used (data, item, value). That way you don’t have to reinvent the component again to use JSON with different variable names like in your sample. The code is looking for this specific variable names in the JSON object.
If you still wanted to use yours Justin structure, you could try pasting the JSON into the prompt and tell it that it is your new json structure. Not sure if that will work right off the bat or not. The AI is stubborn sometimes.
The only thing left would be to instruct the component to decrement the number. Still curious how to plan to to update rows with the updated counts though. If you are updating multiple rows, you would have to involve the API and building a JSON payload to upload multiple. You would also need the RowID for each item. I don’t know…it just feels like a complicated approach that you are taking, and I’m not sure how you plan for it to all work once the form is submitted.
On a simpler level, you could just use the native multi select choice component, display the item names, but write the RowID. When you submit your form you would end up with a comma delimited list of RowID’s. Then you could create a relation from the the items table to the order table, create a Rollup to count the number of matches, and subtract the Rollup count from the item count. It doesn’t permanently adjust the item quantity, but the math result would be correct as long as you never delete any orders. It’s not the best method, but it’s simpler.
Ultimately some kind of workflow would be best. A choice component the gives you a comma delimited list of selected row IDs or a JSON object with an array of RowID’s and quanties, an action that calls a webhhook, and a webhook workflow that loops through the JSON or comma delimited RowIDs, and decrements from each item row as the loop spins through each row id.
None of this is something I’ve attempted myself, so I didn’t have a good tutorial or best practice. On the other hand, maybe you have a plan worked out, that I’m not aware of, when the order is submitted.
Sorry, I’m throwing a lot out there, but I want to make sure the the process it fully thought out after the submit button is pressed. Reading through your posts again, I guess you do mention allowing only 2 selections. This does make it easier. I think I would still go for the native choice component. Write or the row IDs for the selections. Split them into an array. Create 2 single value columns to get each individual row id. Create 2 single relations to link to each respective item. Then set up a workflow that will decrement each item by 1 the through each relation. Maybe that would be best…