Home › Forums › General Issues › Update ACF field when WooCommerce order status switched to “Processing” › Reply To: Update ACF field when WooCommerce order status switched to “Processing”
I eventually solved the problem by switching hooks to woocommerce_checkout_update_order_meta
So that it saves on order creation and not on order status processing, because it works and it also is fine for the particular usecase.
I assume on this webhook the saving of the ACF field is only running once so the issue brought up by John doesn’t happen.
Thank you John for your feedback and knowledge as it was invaluable for me to learn more about how ACF works! some of this stuff would have been a headache to figure out on my own.
add_action( 'woocommerce_checkout_update_order_meta', 'update_product_custom_field_', 10, 1 );
function update_product_custom_field_( $order_id ) {
// Generate the shipping number using the order ID
$shipping_number = 'SHIPPINGNUMBERTEST';
// Update the custom field for the shipping number
if (function_exists('update_field')) {
update_field( 'order_shipping_number', $shipping_number, $order_id );
}
}
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.