Woocommerce Order Meta Data Mapping

I am newer to Make and really enjoying the power of this product - prior I was very familiar with being “zapped”.

As I have been re-building all of my processes here, one item I initially struggled with was various modules I use with wordpress and woocommerce, being able to get the resulting data from those fields. A different topic is why some show up laid out under “additional fields” while other inputs don’t, but what is consistent is the data will always show up under Meta Data.

What was not clear to me initially and maybe not to others, or even new users in the future, is how easily you can grab that data for your various modules.

In this example I have about 25 Meta Data values that pulled during this “get” order.

Any of these data points can be used simply by calling for them using “key” with a get command. The key will be the slug (which can typically be found in the specific module you used to build the custom field in woocommerce).

So in this example if I wanted to use the _shipping_store_number, the _billing_store_number, _billing_delivery_contact_name, phone, and email, to fill in data in a google sheet row, or a database entry such as Knack, I can get those values using the following “get” command.

please note my “metaData” in my instance is 6. - the numeric value displaying for you would be different - you can find your value by typing the commands out and dragging the metaData into the field.

{{get(map(6.metaData; ‘value’; ‘key’; ‘_shipping_store_number’); 1)}}

{{get(map(6.metaData; ‘value’; ‘key’; ‘_billing_store_number’); 1)}}

Here is what it looks like being written into a field in Knack.
Make_SC3

Hope this helps others more quickly get to the results you need when creating scenarios using wocommerce or any other systems where the data is written in an array and you are not needing to parse it through an iteration for use.

7 Likes

Hello there @Ward_McMillen welcome to the community :wave:

I just wanted to quickly jump in and say thank you for sharing what you’ve figured out with us. This might totally come in super handy to many users in the future. Thanks for thinking about the community :purple_heart:

Hello Ward_McMillen,

Thanks for this showcase, it’s helpful for me.

But in my own case, the Meta Data I want to extract from a Woocommerce order is not directly available, it is located in a collection :

I can’t find an easy way to get for example the code & name in the “value” collection.

Someone has an idea ?
Thanks for your help.
Sylvain

1 Like

I haven’t ran into that deep of a collection “yet”… I would have to “tinker” with it to see if you could create an array for that and then try to extract? Not sure, but no to this point I have not yet came across or needed to deal with this. But I am glad you exposed the possibility.

2 Likes

Yes, I have the same problem, and it is a nightmare to get those values (for a newer and not developer like me).

I’m asking ChatGPT to help me, but I didn’t achieve it … Yet!

Has anyone figured this out?? I have Metadata that isnt being shown.

Hi guys! Did anyone manage to find a solution for this matter? I’m also facing the same problem…

In the example I showed, you expand the collection to view the metadata - from there you need to create your “get” mapping - such as get( map( “operation - metaData”; value;key;_yourmetastring_name);1)

You can call for this metadata anywhere in your operation once you have the key name. But you will have to find your keyname by expanding your collection - I would keep expanding it until it is revealed. You can see in my example I had it expanded. Hope this points you in the right direction. The key should be there.

Thank you for your reply Ward_McMillen! The problem is that I’m unable to retrieve the information. It reads the "Metadata but it’s unable to read the key and value. Basically I want to retrieve and map the data from _sameday_shipping_locker_id. I took two screenshots so you can better see what I’m talking about.



Ok - looking I see what your up against the value is that entire string - You would have to bring that string in and then parse out the bits you don’t want to use. It’s possible - it follows the path I was laying out - but your value is just a more complicated bit of data than just the simple value you are looking at. That said there should be a way to parse your data for just the bit your needing with in your final result.

Hi and thank you for your reply! You gave me a good idea! I made a function on WordPress that actually parses that string extracts the locker ID and saves it separately in Post Meta Order. Now when the module grabs data the Locker ID also shows as a standalone in the Meta Data. But it’s still not working… It says that the value is empty but if you look under the collection it shows the value… Any idea what I’m doing wrong? See the images for reference. Thanks a lot for all the support.



I might be wrong, but it looks like a minor syntax issue. I think I see the task your trying to pull from is 1 and your key is _locker_id - with those variables in mind - try deleting everything in the variable value box copying and pasting this string -

{{get(map(1.metaData; ‘value’; ‘key’; ‘_locker_id’); 1)}}

Noup… Unfortunately, I get the same error…

I finally managed to do it. It was so simple… :slight_smile:
This is the mapping function I use: {{1.metaData[22].value}}
The number between the square brackets (in my case 22) is an index that determines which element of the array will be used. Leaving it empty defaults to the first element and that’s why I was unable to retrieve the data… Thanks once again for the support!