on the checkout page, add the text field to input the code:
<input type="text" name="merchentCode" id="merchentCode" value="" />
on the confirm page, there will be a collection of hidden elements near the bottom
add another hidden element using the sale name as the text field on the checkout page to capture the value that is posted:
<input type="hidden" name="merchentCode" id="merchentCode" value="<?php echo((isset($_POST["merchentCode"]))?$_POST["merchentCode"]:"") ?>" />
next add a Set Session Value behavior. on the Server Behaviors panel, click the plus button and select eCart -> General -> Set Session value. set the trigger to any page post. Set the name to merchentCode and for the value, select the merchentCode form element.
In your orders table, create a merchentCode column, then edit the store order summary behavior on the confirm page to bind the merchentCode column to the merchentCode form element