This article helped me out: https://wisdmlabs.com/blog/add-custom-data-woocommerce-order/
The values I’m adding are hidden from the customer at the time of the order and will be updated at delivery. I only needed the functions from step 5 & 6 of the article and I made some slight changes for my purposes.
Anyway I hope that article helps others trying to do the same. I added the following to my theme’s functions.php.
//Custom Item Meta
add_action('woocommerce_add_order_item_meta','wdm_add_values_to_order_item_meta',1,1);
if(!function_exists('wdm_add_values_to_order_item_meta'))
{
function wdm_add_values_to_order_item_meta($item_id)
{
global $woocommerce,$wpdb;
wc_add_order_item_meta($item_id,'pid',0);
wc_add_order_item_meta($item_id,'start_count',0);
wc_add_order_item_meta($item_id,'end_count',0);
}
}
add_action('woocommerce_before_cart_item_quantity_zero','wdm_remove_user_custom_data_options_from_cart');
if(!function_exists('wdm_remove_user_custom_data_options_from_cart'))
{
function wdm_remove_user_custom_data_options_from_cart()
{
global $woocommerce;
// Get cart
$cart = $woocommerce->cart->get_cart();
// For each item in cart, if item is upsell of deleted product, delete it
foreach( $cart as $key => $values)
{
if ( $values['pid'] == 0 ){
unset( $woocommerce->cart->cart_contents[ $key ] );
}
if ( $values['start_count'] == 0 ){
unset( $woocommerce->cart->cart_contents[ $key ] );
}
if ( $values['end_count'] == 0 ){
unset( $woocommerce->cart->cart_contents[ $key ] );
}
}
}
}