Untitled
webwizards
plain_text
9 months ago
861 B
18
Indexable
add_action('marketking_order_split_created', function($order_id){
$order = wc_get_order($order_id);
if (!$order) {
return;
}
$parent_id = $order->get_parent_id();
if (!$parent_id) {
return;
}
$parent_order = wc_get_order($parent_id);
if (!$parent_order) {
return;
}
// Copy meta data
$meta_keys = [
'_billing_wooccm14',
'_billing_wooccm13',
'_additional_wooccm0',
'_additional_wooccm1',
'_additional_wooccm2'
];
foreach ($meta_keys as $key) {
$value = $parent_order->get_meta($key);
if ($value !== '') { // Only update if value exists
$order->update_meta_data($key, $value);
}
}
$order->update_meta_data('is_child_order', 'yes');
$order->save();
}, 10, 1);Editor is loading...
Leave a Comment