I came across this post looking for a solution for multiple resubmissions due to update_post_meta. Here’s my solution after looking at these posts wordpress get_post_meta check if multiple values set Prevent processing data multiple times in Woocommerce thankyou hook :
<?php
global $post;
$post = $order_id;
if ( isset( $_POST['submit'] ) ){
echo 'Update nicht';
} else
// Checking if this has already been done avoiding reload
if ( get_post_meta($order_id,"frontstrasse",true)!="" && get_post_meta($order_id,"fronthausnr",true)!="" {
return; // Exit if already processed
}
update_post_meta( $order_id, 'Strasse', sanitize_text_field( $_POST['frontstrasse'] ) );
update_post_meta( $order_id, 'Haus-Nr', sanitize_text_field( $_POST['fronthausnr'] ) );
}
$istrasse = get_post_meta($order->id, 'Strasse', true );
$ihausnr = get_post_meta($order->id, 'Haus-Nr', true );
?>
<form method="post" action="">
<label>Strasse</label><input type="text" name="frontstrasse" value="<?php echo $istrasse ?>" />
<label>Haus-Nr</label><input type="text" name="fronthausnr" value="<?php echo $ihausnr ?>" />
<input type="submit" value="save" name="frontsubmit" />
</form>