Pick data labels not quite working
-
I’ve got a pod named “organisation” and in it, I have a relationship (Multi Select) field “org_all_orders” which links to Woocommerce orders (custom post type “shop_order”). I’ve extended the shop_order POD to include the relationship field and everything works fine … except … the title for “shop_order” doesn’t include the order number, which is very important, so I’ve changed the Display Field in Select List to @id. Then to avoid accidentally adding the wrong order numbers I have the following code to make the labels more descriptive (it has the order number, firstname, lastname date and total) in the organisation pod:
It works fine upon selecting the order number, like so:
https://imgur.com/j6awa3Y
And before saving, everything looks good:
https://imgur.com/UsBE2by
But after saving it just reverts back to the @id in the UI:
https://imgur.com/aN1z69c
This is same on both the front and back ends. Am I missing something really obvious? I’ve tried different filter priorities without much success. Any help is appreciated ??add_filter('pods_field_pick_data_ajax_items', 'show_first_and_lastname_in_pick_field', 1, 6); add_filter('pods_field_pick_data', 'show_first_and_lastname_in_pick_field', 1, 6); add_filter('pods_form_ui_field_pick_data', 'show_first_and_lastname_in_pick_field', 1, 6); function show_first_and_lastname_in_pick_field($items, $name, $value, $options, $pod, $id) { if ("org_all_orders" == $name) { foreach ($items as $key => &$data) { if ($data['id']) { $order_id = $data['id']; $order_meta = get_post_meta($order_id); $first_name = get_post_meta($order_id, '_billing_first_name', true); $last_name = get_post_meta($order_id, '_billing_last_name', true); $date = get_post_meta($order_id, '_wcpdf_invoice_date_formatted', true); $full_name = $first_name . ' ' . $last_name; $order_total = "$" . get_post_meta($order_id, '_order_total', true); $label = $order_id . ' ' . $full_name . ' ' . $date . ' - ' . $order_total; $data['text'] = $label; $data['name'] = $label; } } } return $items; }
- The topic ‘Pick data labels not quite working’ is closed to new replies.