Support

Account

Home Forums Backend Issues (wp-admin) WooCommerce w/ ACF Orders Backend HELP!!!

Helping

WooCommerce w/ ACF Orders Backend HELP!!!

  • Hello everyone, I am setting up a woocommerce shop and one of the things we would like to offer our customers is an ‘Order Completed’ email that tells them their tracking number and their shipping service once we have confirmed that we have shipped the package.

    However, I am having some trouble. I set up something with ACF that lets employees select a shipping service and enter a tracking number. When we set the status of the order to complete and select the option in WooCommerce to update the customer, the values don’t show up initially. We have to send it twice for the values to actually come through. I have shared my code below and I am begging for someone to help me understand how to fix this issue. I think I need to find a filter or something that defines a new property for the $order once those values are entered or selected, but I’m not too too sure on how to do that.

    `
    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 = “http://www.fedex.com/Tracking?tracknumbers=”;
    break;
    case “USPS”:
    $trackingURL = “https://tools.usps.com/go/TrackConfirmAction?tLabels=”;
    break;

    }

    if($status == “completed”){
    ?>

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

    <td>
    <a href=”<?php echo ($trackingURL . $trackingNumber) ?>”>
    <?php echo $trackingNumber; ?>
    </a>
    </td>
    <td><?php echo $track; ?></td>

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

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

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

You must be logged in to reply to this topic.