• dscp8g

    (@dscp8g)


    Hi

    On the order details page, i’d like to display the customer email in a distinct div in raw format (not with the mailto tag by default)

    I played around with the portion of code below whichi s found in class-wc-meta-box-order-data.php file
    but I haven’t been able to get the email field by itself

    <?php
    // Display values.
    if ( $order->get_formatted_billing_address() ) {
    echo '<p>' . wp_kses( $order->get_formatted_billing_address(), array( 'br' => array() ) ) . '</p>';
    } else {
    echo '<p class="none_set"><strong>' . esc_html__( 'Address:', 'woocommerce' ) . '</strong> ' . esc_html__( 'No billing address set.', 'woocommerce' ) . '</p>';
    }

    $billing_fields = self::get_billing_fields( $order, 'view' );

    foreach ( $billing_fields as $key => $field ) {
    if ( isset( $field['show'] ) && false === $field['show'] ) {
    continue;
    }

    $field_name = 'billing_' . $key;

    if ( isset( $field['value'] ) ) {
    $field_value = $field['value'];
    } elseif ( is_callable( array( $order, 'get_' . $field_name ) ) ) {
    $field_value = $order->{"get_$field_name"}( 'edit' );
    } else {
    $field_value = $order->get_meta( '_' . $field_name );
    }

    if ( 'billing_phone' === $field_name ) {
    $field_value = wc_make_phone_clickable( $field_value );
    } elseif ( 'billing_email' === $field_name ) {
    $field_value = '<a href="' . esc_url( 'mailto:' . $field_value ) . '">' . $field_value . '</a>';
    } else {
    $field_value = make_clickable( esc_html( $field_value ) );
    }

    if ( $field_value ) {
    echo '<p><strong>' . esc_html( $field['label'] ) . ':</strong> ' . wp_kses_post( $field_value ) . '</p>';
    }
    }
    ?>
Viewing 1 replies (of 1 total)
  • anastas10s

    (@anastas10s)

    Hi there @dscp8g ,
    Helping out with custom coding of this nature is outside the scope of support that our support staff can help out with here, although I would recommend the following:

    • Running the exact question you’re asking, along with the code provided, through an AI platform like ChatGPT for recommendations/changes to your code;
    • Checking whether there are existing plugins in the WordPress plugin repository that might be doing that already.
    • Joining our WooCommerce Slack community (it does have a developer channel where you can ask coding questions):?https://woo.com/community-slack/

    Hope it helps!

Viewing 1 replies (of 1 total)
  • The topic ‘How to display customer email in within the meta order data box’ is closed to new replies.