• Resolved Peninah

    (@highlight_creative)


    I’m adding some custom messages to the top of the customer invoice.

    I want to write “Your username is XXX.” I tried a number of things. The closest I have gotten is this:

    <?php printf( __( "Username %s", 'woocommerce' ), $order->customer_user ); ?>

    But this produces the user’s ID, not their username.

    I have spent a long time searching as I think there’s probably a simple answer I’m missing, but nothing has come up yet…

    Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Add this line to get all user data for that customer by id:
    <?php $user_info = get_userdata($order->customer_user);?>

    then print like this :

    <?php printf( __( "Username %s", 'woocommerce' ), $user_info->user_login ); ?>

    Thread Starter Peninah

    (@highlight_creative)

    THANK YOU!! All is well ??

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Add username to customer invoice’ is closed to new replies.