• Resolved oberning

    (@oberning)


    Hi,

    Do you know the way how to add a custom user field to the order as meta data?
    I tried some things but I am getting errors all the time:

    // Add the user meta as order meta data
    add_action( 'woocommerce_order_status_wordt-verwerkt', 'add_wefactemail_to_order_meta_data', 10, 2 );
    function add_wefactemail_to_order_meta_data( $order ) {
      $user_id = $order->get_user_id(); // Get the user id
      $wefactemail = get_user_meta( $user_id, 'KVK_nummer_2', true );
      $order->update_meta_data( 'WeFact_Billing_Email', $wefactemail );
    }

    Also, I am using the custom order status plugin from WooCommerce. So I am trying to add the action when we are updating the order status to the custom order status “wordt-verwerkt”.

    I hope you can help me out.

    Best,
    Olga

Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘add user meta to order meta’ is closed to new replies.