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”
The post is updated to Processing through native woocommerce usage ( inside the Order, it is switched to status “processing” and then pressed the button “Update”.
The field is a standard text field, available in the Order page to be edited, this is correct.
By the way when running the code with some form of debugging like this
add_action( 'woocommerce_order_status_processing', 'update_product_custom_field_', 10, 1 );
function update_product_custom_field_( $order_id ) {
// Log start of function
error_log("Updating custom field for order ID: $order_id");
// Generate the shipping number using the order ID
$shipping_number = 'SHIPPINGNUMBERHERE';
// Check if ACF function exists and update the custom field
if (function_exists('update_field')) {
$result = update_field( 'order_shipping_number', $shipping_number, $order_id );
if ($result) {
error_log("Successfully updated order_shipping_number for order ID: $order_id");
} else {
error_log("Failed to update order_shipping_number for order ID: $order_id");
}
} else {
error_log("ACF update_field function not found.");
}
}
it prints to the logs “Successfully updated order_shipping_number for order ID:”
which makes it seem like the update_field is running correctly, but for some reason is not saving?
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.