Support

Account

Home Forums General Issues Adding User Form field to woocommerce Email

Solving

Adding User Form field to woocommerce Email

  • Hi
    Im struggling to add a field i have created to woocoomerce email. The field appears under the users profile in WordPress. Its an internal name that we use to distinguish customers and is entered by an admin. – This all works fine.

    I cannot get this field to appear in our admin-new-order email.
    field name is escentia_internal

    I have tried code snippets for both functions file and woocommerce email template. All result in an error on front end.
    One example below.
    <?php
    // Get the $order ID (WooCommerce version compatibility)
    if ( version_compare( WC_VERSION, ‘3.0’, ‘<‘ ) ) {
    $order_id = int_val( $order->id ); // Older than 3.0
    } else {
    $order_id = int_val( $order->get_id() ); // 3.0+
    }

    $internal = get_field(‘escentia_internal’, $order_id );

    if( $internal ){
    echo ‘<p>’ . $internal . ‘</p>’;
    }
    ?>

    Your help would be greatly appreciated

  • I’m also having difficulty fetching ACF fields into the admin-new-order email. I believe the issue is related to hook order when that particular email is sent (ACF is not loaded yet?).

  • It could be that ACF is not loaded yet, but I would find it unlikely that WC is attempting to send an email before WP has initialized.

    What is the error you are getting?

  • My issue was resolved by changing the priority of some other actions so that the options fields were available. Specifically I had my acf_add_options_page calls inside the init hook instead of the acf/init hook, and the taxonomies referenced inside those functions were not yet registered, so I needed to change their registration priority as well.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.