
Hi,
I created a custom field to add the tracking number in the woocommerce order page.
The problem is that in order to work, I have to fill in the field, save the page, then I have to change the order to complete and resave the page.
It’s like if the information entered in the field was not saved. Is there a way I can add a save button under my custom field? This could fix the issue.
The information entered would be registered in the wordpress DB and then I could only switch the order status to complete, in order to send the tracking number to the client.
Here is the code
// define the woocommerce_email_before_order_table callback
function action_woocommerce_email_before_order_table( $order, $sent_to_admin, $plain_text, $email ) {
if (get_field('trackingnumberups', $order->get_id())) { // Only show if field is filled
?>
<h3>Your tracking number: <?php the_field('trackingnumberups', $order->get_id()); ?></h3>
You may track your order with the number above, here: <a style="color: #0073aa;" href="https://www.ups.com/tracking/tracking.html">UPS Tracking</a>
<?php
}
};
// add the action
add_action('woocommerce_email_before_order_table', 'action_woocommerce_email_before_order_table', 10, 4 );
Hello @bigrat95
This might solve your problem:
ACF For Dokan PRO
Thanks
More than likely the email is sent before ACF has saved the fields.
If this is the case you can access the value intered into the field in $_POST['acf'][YOUR FIELD KEY]
<?php echo $_POST['acf']['field_XXXXXXX']; ?>
Great, thank you John. It did solved the issue.
Hi! Is there something for tracking emails from a specific user?