• Resolved bigrat95

    (@bigrat95)


    Hi,

    Is there someone who use ACF with Woocommerce ?

    I created a custom field to send the Additional Info to our clients email once the order is completed.

    Here is the code:

    add_action (‘woocommerce_order_details_after_order_table’, ‘acf_additionalinfo’, 20);

    function acf_additionalinfo( $order ) {

    if (get_field(‘additionalinfo’, $order->id)) { // Only show if field is filled

    ?>
    DHL: <?php the_field(‘additionalinfo’, $order->id); ?>

    <?php

    }

    }

    It work well but it seems that I have to fill in the field, save the page, then I have to change the order to complete and resave the page.

    Else, the additiona linfo will not be included in the order confirmation email.

    Here is a topic about this: https://support.advancedcustomfields.com/forums/topic/showing-acf-field-on-woocommerce-order-page/

    I am starting to think that it is a limitation in the WC filter.

Viewing 4 replies - 1 through 4 (of 4 total)
  • mtruitt

    (@mtruitt)

    Based on the provided code. There is nothing here that would add that to any email in WooCommerce. That would add it on the order page for that specific order if it exists.

    Example:
    https://yourdomain.com/my-account/view-order/236/

    And it would display between the end of the order details and the billing address.

    Should be a filter with woocommerce_email_order_meta_fields

    Thread Starter bigrat95

    (@bigrat95)

    Yes, sorry this was the wrong code, but I changed it for what you mentionned and it doesent work. I still have to fill in the field, save the page, then I have to change the order to complete and resave the page.

    
    // define the woocommerce_email_order_meta_fields callback 
    function filter_woocommerce_email_order_meta_fields( $array, $sent_to_admin, $order ) { 
        // make filter magic happen here... 
        if (get_field('additional-info', $order->get_id())) { // Only show if field is filled
     
    ?>
            <h3>Additional Info: <?php the_field('additional-info', $order->get_id()); ?></h3>
                   
            <?php 
            
        }
    
    }; 
             
    // add the filter 
    add_filter( 'woocommerce_email_order_meta_fields', 'filter_woocommerce_email_order_meta_fields', 10, 3 ); 
    
    
    Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    Hey there! Were you able to find a solution to this? If so, it would be great if you can share so that we can all learn from it.

    Kenin

    (@kbassart)

    Automattic Happiness Engineer

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Woocmmerce order complete custom field’ is closed to new replies.