0

I need to change products in order before order is created, because I created extra field in cart and I want to save it also in order to make it visible on admin panel after order. Now its saved only in cart but after order ready not visible anymore.

What action should I use to edit order and save in this place extra field saved in cart?

1 Answers1

0

Ok, I created solution.

  add_action( 'woocommerce_add_order_item_meta', 
 'add_custom_fields_order_item_meta', 20, 3 );
  function add_custom_fields_order_item_meta( $item_id, 
  $cart_item, $cart_item_key ) {
  // here we updating order by adding custom field created before in cart
  if (isset($cart_item['adds'])) wc_update_order_item_meta( $item_id, 'adds', $cart_item['adds'] );
  }