You can put your script in a loop to add multiple items. The only detail that is not clear is how you would get the individual serial numbers. Presumably you have a table of these?
Does that table have a SKU or other product ID field?
Is there a status field to update as each item is sold?
If so, your script can use List or ExecuteSQL to set a variable to a list of these serial numbers for your loop to use to put into your line items and to update the status field to mark the record as "sold".
Thank for your suggestion, I will try and comeback to tell you.
In Stock table I have SKU (portal in stock table) to keep serial number of any product and SKU will link to Sale detail table (portal in Sale table) in order to receive any detail of sale (product name, serial, price, model). I use Stock ID to link them into relationship and when a serial number have been sold the status at SKU will be changed from "Received" to "Sold" by the script that I show you.
SKU at Stock table
You also probably want to correct your spelling error: I'm assuming you mean..."Canceled".