I have added some fields during checkout process and I need to store it in my DB and connect them to the order.
Right now my code works but it add the data to the subscription, not the connected order.
This is my code:
foreach($this->fields as $key=>$value){
if (!empty($_POST[$key]) && trim($_POST[$key]) != '') {
update_post_meta($order_id, $this->prepare_field_name($value['label']), sanitize_text_field($_POST[$key]));
}
}
And this is the action:
add_action('woocommerce_checkout_update_order_meta', [$this,'zerouno_customise_checkout_field_update_order_meta_for_subscriptions']);
How can I get the parent order and add the same data to it?