I am trying to setup an API integration with PDF Generator API that will create multiple labels for me within a single API call. For an example of what I mean go to the following URL and look at the " Product Labels" example; PDF Generator API | Document templates for automated PDF creation
Description: I would like to take several input values (e.g. Title, Description, Price, Discounted Price, Barcode) and convert them into a JSON array, multiplied by another input value that is a number.
Example #1: I input a Title, Description, Price, Discounted Price and Barcode into their respective inputs and I leave the number input box blank. When I send the API call it will send the following JSON payload and create a single label on the template;
{
"title": "Label Title",
"description": "Label Description",
"price": "8.00",
"discounted_price": "4.00",
"barcode": "123456789101"
}
Example #2: I input a Title, Description, Price, Discounted Price and Barcode into their respective inputs and I set the number input box to 4. When I send the API call it will send the following array in a JSON payload and create four labels on the template;
[
{
"title": "Label Title",
"description": "Label Description",
"price": "8.00",
"discounted_price": "4.00",
"barcode": "123456789101"
},
{
"title": "Label Title",
"description": "Label Description",
"price": "8.00",
"discounted_price": "4.00",
"barcode": "123456789101"
},
{
"title": "Label Title",
"description": "Label Description",
"price": "8.00",
"discounted_price": "4.00",
"barcode": "123456789101"
},
{
"title": "Label Title",
"description": "Label Description",
"price": "8.00",
"discounted_price": "4.00",
"barcode": "123456789101"
}
]
I am not saving any of this to the DB. They are all coming from the inputs on the page. I am not opposed to saving this information to the DB if need be though. I would simply like to figure out what the best practice would be to take a single text, multiply it by a number input value and send that many of the text value as a JSON array via the API call.
Any help would be greatly appreciated.
Edited from the original post for clarity,