regarding the function_exists check I put this directly in the code that gets called by the original form submission. When does the function get loaded?
== veering off to another part of the thread ==
As a hack I added this to class-wc-checkout.php in the middle of all the other meta fields being saved.
'$unique_code = $_SESSION['clientwebcode'];
update_post_meta( $order_id, '_webcode', $unique_code) ;'
And this works insofar as I now have a postmeta entry with the orderid and the code.
So how to correctly do this so it doesn't get wiped out by updating.