Hi,
I created a custom field to add manually 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 my 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 );
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
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 Privacy Policy. If you continue to use this site, you consent to our use of cookies.