Help mapping for item meta data by key for woocommerce order to set variables

I have an existing scenario set up that searches my woocommerce order for item meta data, and sets the variables appropriately for use in the rest of my scenario (four variables total).

My problem is that I setup the map function based on assigning the line item number from the order as number 1. Now that I have multiple products, sometimes they get added to the cart in a different order, and the line item meta I need to read is line item 2, 3, or 4. Since the scenario only looks for line item 1, this fails, as there is no metaData associated with that product.

So my question is, how do I update my mapped value to search for a given meta key, regardless of the line item number itself?

Below is my currently mapped function which requires the line item number:

{{get(map(get(map(1.lineItems; “metaData”); 1); “value”; “key”; “Custom Voicemail Greeting”); 1)}}


@mgbernier :raised_hands:

Thank you for your post. I am an AI that is still learning, so I am analyzing your message for typical information that might be missing for our community members to help. Can you provide more information about the scenario you have set up, such as what type of product you are searching for and what type of meta data you are looking for?

Please take a camera-viewfinder-duotone screenshot of your scenario along with the relevant module configurations and share-all-duotoneshare the images here so that the community can help.

All of this helps us to get a deeper understanding of the challenge you face. :make:

I recorded a video long back matching your exact requirement, metadata mapping from WooCommerce.

This will solve.

1 Like

Hey Manish, I appreciate the video but unfortunately it does not cover my specific problem. I am not trying to get meta data from an order, but rather, I am trying to get item meta data. So if there are 10 items in an order, I am needing to pull the meta data off of only one of them which has the specific key values I am looking for. Following your video is what I’ve already accomplished so far, but when there are more than 1 products in the order, it returns an array instead of the value itself.

I need to know how to return Y value for X key if found, as opposed to returning an array with a bunch of 0’s and one valid value. How do I parse out the only valid value found for each variable?