I'm trying to add custom product meta to order item meta when adding products to the order from the admin. This is my code, which does nothing in the backend ...
// Order items: Save product "location" as order item meta data
add_action( 'woocommerce_ajax_add_order_item_meta', 'action_before_save_order_item_callback' );
function action_before_save_order_item_callback($item, $cart_item_key, $values, $order) {
if ( $location = $values['data']->get_meta('location') ) {
$item->update_meta_data( 'location', $location ); // Save as order item meta
}
}