Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • It may be indirectly caused from extened Pods. For instance, I have an extended Pod (shop_order) that definitely doesn’t have the tabs no matter what I do. Then I visit my organisation Pod, which I created, which is missing the tabs. Saving it again or re/deactivating the REST API brings the tabs back. Perhaps a session variable inadvertently saved or not cleared?

    Thread Starter wpepro

    (@wpepro)

    Ah yes, checking for null is just force of habit from me, but you’re right – you can omit this without any issues ??

    I found the same. It’s inconsistent to replicate, but if you make some settings changes (I found turning the REST API off and on again or vice versa) or just saving the Pod again, it comes back (only to disappear again later on!)

    Thread Starter wpepro

    (@wpepro)

    For anyone else stuck/interested, I figured it out. Two completely different methods, but watch out for the difference between “your_fieldname”, “pods_meta_your_fieldname” and “pods_field_your_fieldname”:

    add_filter('pods_field_pick_data_ajax_items', 'labels_in_pick_field_ajax', 1, 6);
    add_filter('pods_field_pick_data', 'labels_in_pick_field_data', 1, 6);
    
    function labels_in_pick_field_ajax($items, $name, $value, $options, $pod, $id) {
        if ("org_all_orders" == $name) {
            foreach ($items as $key => &$data) {
                if ($data['id']) {
                    $data['text'] = get_woo_data_label($data['id']);
                    $data['name'] = $data['text'];
                }
            }
        }
        return $items;
    }
    
    
    function labels_in_pick_field_data($items, $name, $value, $options, $pod, $id) {
    	
    	// pods_meta_ prefix for Pods backend, pods_field_ prefix for front-facing Pods form
        if ("pods_meta_org_all_orders" === $name ||	 "pods_field_org_all_orders" === $name ) {
            if (is_array($items) && !empty($items)) {
                foreach ($items as $key => $item) {
                    if (!is_null($item)) {
                        $items[$key] = get_woo_data_label($items[$key]);
                    }
                }
            }
        }
        
        return $items;
    }
    
    function get_woo_data_label($order_id) {
    	// return whatever you like :) 
    	$meta_values = get_post_custom($order_id);
    
    	$first_name = isset($meta_values['_billing_first_name']) ? $meta_values['_billing_first_name'][0] : '';
    	$last_name = isset($meta_values['_billing_last_name']) ? $meta_values['_billing_last_name'][0] : '';
    	$date = isset($meta_values['_wcpdf_invoice_date_formatted']) ? $meta_values['_wcpdf_invoice_date_formatted'][0] : '';
    	$order_total = isset($meta_values['_order_total']) ? '$' . $meta_values['_order_total'][0] : '';
        $full_name = $first_name . ' ' . $last_name;
    
    	return $order_id . ' ' . $full_name . ' ' . $date . ' - ' . $order_total;
    }
Viewing 4 replies - 1 through 4 (of 4 total)