Home Forums Backend Issues (wp-admin) WooCommerce $order woes


WooCommerce $order woes

  • In the code below, I am trying to get the ACF fields of ‘shipping_service’ and ‘tracking_number’ to show up in my order-complete emails to customers, but it only shows up the second time I send emails to my customers. It’s been stressing me out for months and I can’t solve this by myself. Will any of you PLEASE help me?

    add_action( ‘woocommerce_email_after_order_table’, ‘woocommerce_email_after_order_table_func’ );
    function woocommerce_email_after_order_table_func( $order ) {
    $ship = get_field($order->id, ‘shipping_service’, true);
    $track = get_field($order->id, ‘tracking_number’, true);

    $status = $order->get_status();
    $shippingService = get_post_meta($order->id, ‘shipping_service’, true);
    $trackingNumber = get_post_meta($order->id, ‘tracking_number’, true);
    $trackingURL = ”;
    switch ($shippingService) {
    case “FedEx”:
    $trackingURL = “”;
    case “USPS”:
    $trackingURL = “”;


    if($status == “completed”){

    <h3>Shipping Information:</h3>
    <td>Tracking Number: </td>

    <?php echo $trackingNumber; ?>

    <td><?php echo $track; ?></td>

    <td>Shipping Service: </td>
    <td><?php echo $shippingService; ?></td>
    <td><?php echo $ship; ?></td>

    $trackingURL = NULL;
    } else {
    <h3>When we have your order shipped, we will send an email with that information.</h3>

    • James

    • July 14, 2019 at 2:04 am

    Hi @lightsage88

    It’s most likely that you are trying to load the field values before they are actually saved into the database.

    Kindly try changing the priority of the ‘woocommerce_email_after_order_table’ to above 10 to see if you are able to load the field.

    Hope to hear from you soon.

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

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.