The main missing detail is that the loop in your script never modifies the $QuantityOrdered variable
You need this step located between the Loop and End Loop steps:
Set Variable [$QuantityOrdered ; value $QuantityOrdered - 1 ]
To reduce the count in this variable by 1 each time the loop is executed.
Your Exit Loop step should exit the loop when this variable reaches 0
Exit Loop If [ $QuantityOrdered < 1 ]
And I don't know the purpose of $$ButtonSave, but you do not need to set it to 1 over and over within the loop.
You start allright: set a variable that represents the number of orders.
Then you start a loop, with the condition Exit Loop If x = x. This condition is met immediately, so the loop will never take place. You should use the variable as a counter:
Exit Loop If $quantityOrdered = 0
Set Variable [$quantityOrdered; $quantityOrdered - 1]
Hope this helps.
We were focused on getting the loop to work.
You also need steps for creating a new record. How you do that depends on the context in which this script executes.
If your script is executing on a layout based CustomerOrders, you need a new/Record script step. If CustomerOrders represents a record from a related table, you'll need to do a bit more scripting--either to change to a layout based on CustomerOrders, interact with a portal (This works, but I recommend against this option), or via a method known as MagicKey.