create a lookup recordset that searches the order details table and filters the discount code column on the discount code form element.
now add a set session value behavior, on the server behaivors panel, click the plus button and select eCart -> General -> Set Session Value.
Set the trigger use the lookup recordset is empty.
Set the name to "discountUsed"
Set the value to "false"
Now in the eCart object, edit the discount code rule. I addition to the triggers that are already in place, add 2 more:
Session variable discountUsed exists
Based on session variable value:
If the session discountUsed has a value equal to false
you may have to make sure that the set session value code is after the lookup recordset code.