{"id":16708840,"date":"2023-05-03T22:42:10","date_gmt":"2023-05-03T22:42:10","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/custom-column-with-custom-field\/"},"modified":"2023-05-03T22:42:10","modified_gmt":"2023-05-03T22:42:10","slug":"custom-column-with-custom-field","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/custom-column-with-custom-field\/","title":{"rendered":"Custom column with custom field"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Hi, I&#8217;m using premium plugin version and I want to add custom column (named &#8216;MyColumn&#8217;) in the invoice template, with product custom field value when there&#8217;s any, and I tried with:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter('wf_pklist_product_table_additional_column_val', 'wt_pklist_add_custom_col_vl', 10, 6);\n\nfunction wt_pklist_add_custom_col_vl($column_data, $template_type, $columns_key, $_product, $order_item, $order) {\n\n\t$customField = get_field('custom_field_name');\n\n\tif($columns_key == 'MyColumn') {\n\t\t$column_data = implode( ', ', $customField );\n\t}\n\treturn $column_data;\n}\n<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">And this is how I added a column in the invoice template editor: http:\/\/prntscr.com\/4EqSRd1NPevu<br \/><br \/>But the column row is always empty. I&#8217;m using implode since the field it&#8217;s an array with multiple values in some fields (and in some is a single value or without value).<br \/><br \/>Any suggestion on how to achieve this?<\/p>\n","protected":false},"template":"","class_list":["post-16708840","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16708840","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/16708840\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=16708840"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}