0

In WooCommerce I am trying to pull the custom meta field 'greentree_id' from our customers profile and have it show on orders in the admin dashboard.

I have attempted using this code in our functions.php and had no luck.

add_action( 'woocommerce_thankyou', 'orders_from_processing_to_pending', 10, 1 );
function orders_from_processing_to_pending( $order_id ) {

    if ( ! $order_id )
        return;

    $order = wc_get_order( $order_id );
    $user_id = get_current_user_id();

    //Set HERE the meta key of your custom user field
    $user_meta_key = 'greentree_id';

    // Get here the user custom field (meta data) value
    $user_meta_value = get_user_meta($user_id, $user_meta_key, true);


    if ( ! empty($user_meta_value) )
        update_post_meta($order_id, $user_meta_key, $greentree);
    else
        return;

}
7uc1f3r
  • 28,449
  • 17
  • 32
  • 50
Jordan h
  • 23
  • 4

0 Answers0