Home Forums General Issues Displaying values in woocommerce emails


Displaying values in woocommerce emails

  • I’ve set up a group to display in woocommere orders using POST TYPE equal to shop_order.

    I am trying to display the values in my completed order email. This is what I have in my template:

    $tracking 	= get_field('tracking-code');
    $carrier 	= get_field('carrier-name');
    $date 		= get_field('pickup_date');
    <p>Your order has been picked up by <?php echo $carrier; ?> on <?php echo $date; ?>. Your tracking code is <?php echo $tracking; ?>.</p>

    I suspect I am supposed to somehow declare the get_field fields are in the order pages.

    Also, for some reason, the date shows up, but it’s “yyyymmdd” even though in my settings I entered “dd/mm/yy”.

  • I can’t recall ever seeing a topic on trying to put acf values into emails, so this is just a guess. You probably need to include the post ID of where to get the value from, for example the post ID of the order post, and I don’t know if that information is available where you are generating the email. Does WC pass the order/post ID to the mail function?

    $tracking 	= get_field('tracking-code', $post_id);
    $carrier 	= get_field('carrier-name', $post_id);
    $date 		= get_field('pickup_date', $post_id);
    <p>Your order has been picked up by <?php echo $carrier; ?> on <?php echo $date; ?>. Your tracking code is <?php echo $tracking; ?>.</p>
  • Gotta use $order_id instead of $post_id.

    Also remember to triple check your field names…

    • paul115

    • January 9, 2019 at 12:21 pm

    The code above is not working in the admin-new-order.php template

    What am I missing?

    $section 	= get_field( 'location_section', $order_id );
    $column 	= get_field( 'location_column', $order_id );
    $row 		= get_field( 'location_row', $order_id );
    <p>Location of item is: <strong>S<?php echo $section; ?>-C<?php echo $column; ?>-R<?php echo $row; ?></strong></p>
Viewing 4 posts - 1 through 4 (of 4 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.