custom order fields no longer accessing order info
-
I am using your example code for adding in custom order fields, i am fetching the PO from the order meta and the user role from the userdata
function example_custom_order_fields( $fields, $order ) { $new_fields = array(); // add PO number if( get_post_meta( $order->id, '_po_number', true ) ) { $new_fields['customer_po_number'] = array( 'label' => 'Purchase Order Number', 'value' => get_post_meta( $order->id, '_po_number', true ) ); } // add user role if ($order->customer_id !== 0) { global $wp_roles; $user_meta = get_userdata($order->customer_id); $roles = array(); foreach ($user_meta->roles as $role) { $roles[] = $wp_roles->roles[$role]['name']; } $new_fields['customer_role'] = array( 'label' => 'Role', 'value' => ucwords(implode(', ', $roles)) ); } return array_merge( $fields, $new_fields ); } add_filter( 'wcdn_order_info_fields', 'example_custom_order_fields', 10, 2 );
Unfortunately, I am getting no order details from the query any longer (it was working until recently, uncertain when it stopped, we just discovered the invoice was no longer putting the role on orders
the $order value returned is (I JSON encoded it for printing on an invoice to see what i was getting)
{"customer_id":null,"refunds":null}
I am getting the “label” but the value is empty on the document
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘custom order fields no longer accessing order info’ is closed to new replies.