Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
Patrick Kahlo

How to deal with custom field that is an array

Hello,

we have a custom field that comes from JetWooBuilder. We can select one or more specific badges on a product such as “New”, “Bestseller” or “Sold Out”. Thats how we can manage the fields per product in the backend:

Managing fields per product

I can find the field in Admin Columns (_jet_woo_builder_badges) and insert it. However, when I select “Multiple Values” as the field type, the field cannot be edited inline in the product overview. If I select the field as default or text, I can edit it and add or change the value, but it is not saved as an array, which is why the badge is not displayed in the frontend then.

Is there any way I can add the custom field so in AC that one or more specific inputs can be selected in the overview?

Thanks and kind regards
Anil

2 years, 7 months ago
Patrick Kahlo

Sorry, here is the correct link of the image:

Managing the field in backend

2 years, 7 months ago
Tobias Schutter
Developer

Hi there. Serialized data is tough to capture in a single column, because every array is different. If it’s an associative array it can be many levels deep with all different keys. There is no one size fits all solution for this unfortunately. The best way to approach this is to create your own column. A column specifically for your purpose. In this case a column with a meta key called ‘_jet_woo_builder_badges’ which holds an array.

We have created an example column that does exactly this. It’s available on github: https://github.com/codepress/ac-addon-extra-columns/blob/master/classes/Column/Post/SerializedMeta.php

You can change the default meta key ‘my_meta_key’ to ‘_jet_woo_builder_badges’ and the ‘my_sub_key’ to anything you need out of this array. This should enable you to make a single edit within the array. Of course, if it’s a more complex array you can nest it even further.

You can download the repository, and make changes to your liking.

2 years, 7 months ago

You must be logged in to reply to this topic.