I'm having trouble adding custom order item meta data. I have found one way to do it, but it looks terrible.
The code:
add_action('woocommerce_add_order_item_meta', 'func_add_custom_data_to_order_item_meta',1,2);
function func_add_custom_data_to_order_item_meta( $item_id, $values ) {
global $woocommerce,$wpdb;
if(!empty($values['custom'])){
$custom_order_meta = $values['custom'];
wc_add_order_item_meta($item_id, 'custom', serialize($custom_order_meta));
}
}
Is there any way to iterate through the key value pairs and get their contents on a new line each time?