• Resolved rpalach

    (@rpalach)


    Hello, I’m looking to list the ‘User Groups’ the customers are assigned to, into the WooCommerce New Order emails sent to Admins.

    I have already added custom data (into the functions.php file), to display username & ID into these emails, using this code:

    /**

    • @snippet Add customer username and ID to WooCommerce emails
      */
      add_filter( ‘woocommerce_email_customer_details_fields’, ‘add_user_id_to_woocommerce_emails’, 10, 3);

    function add_user_id_to_woocommerce_emails( $fields, $sent_to_admin, $order ) {
    $user_id = $order->get_customer_id();
    $user_info = get_userdata( $user_id );

    $fields[‘user_id’] = array(
    ‘label’ => __( ‘User ID’, ‘woocommerce’ ),
    ‘value’ => $user_id
    );

    $fields[‘username’] = array(
    ‘label’ => __( ‘Username’, ‘woocommerce’ ),
    ‘value’ => $user_info->user_login
    );

    return $fields;
    }

    I found these links, but I can’t seem to get it working?

    https://docs.itthinx.com/document/groups/shortcodes/groups_user_groups/
    https://docs.itthinx.com/document/groups/api/examples/

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi rpalach,

    The group(s) that a customer belongs to, can be returned using the shortcode groups_user_group, which you correctly mentioned.

    For example you can use the shortcode like this

    do_shortcode( '[groups_user_groups user_id='. $user_id .']' );

    in the value key of another custom field. Judging by the snippet you shared, I’m assuming that the syntax is correct but a few tests would be more appropriate.

    Kind regards,

    George

    Plugin Author Kento

    (@proaktion)

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.