I have this setup to add my custom meta fields for products to the item in the order.
1: I use woocommerce_before_add_to_cart_button to create a custom field which is a list field with multiple fields. These are saved as an multidimensional array.
2: I then use woocommerce_add_cart_item_data to add the meta data to the item in the cart when its added to the cart. The multidimensional array are save in one custom field.
3: I then use woocommerce_cart_item_name and woocommerce_order_item_name to display there fields in the cart and in the checkout under the title of the product. I use foreach to display the data from the array. No problem.
4: Last I use woocommerce_checkout_create_order_line_item to save the custom meta data to the order and the item. Here is where I run in to issues with the array, I does not get saved. The other fields, which is not arrays but numbers or variables are no problem.
I have tried these:
$item->add_meta_data( 'team', $values['team'], false );
$item->add_meta_data( 'team', $values['team'], true );
The problem is also that I can not echo or print in that hook to see whats going on or how the data looks like. In the order the field is blank after checkout.
Why can I not just take the array and add to to the custom meta for the item in the order here? It has to do with the fact that its an array because the other fields works, maybe :)


