Hello, I iterate over line items of woocommerce orders.
Now, I want to filter out all the items where a specific key (_woosb_parent_id) is present in the nested MetaData. How should the filter look like? Just to setup a filter like I did does not work.
Thanks for helping out!
output.txt (29.9 KB)
Welcome to the Make community!
This is one way to do it:
Module Export
You can copy and paste this module export into your scenario. This will paste the modules shown in my screenshots above.
-
Copy the JSON code below by clicking the copy button when you mouseover the top-right of the code block
-
Enter your scenario editor. Press ESC to close any dialogs. Press CTRLV (paste keyboard shortcut for Windows) to paste directly in the canvas.
-
Click on each imported module and save it for validation. You may be prompted to remap some variables and connections.
JSON
{
"subflows": [
{
"flow": [
{
"id": 57,
"module": "util:SetVariable2",
"version": 1,
"parameters": {},
"filter": {
"name": "_woosb_parent_id not present",
"conditions": [
[
{
"a": "{{map(56.metaData; \"key\")}}",
"o": "array:notcontain:ci",
"b": "_woosb_parent_id"
}
]
]
},
"mapper": {
"name": "metadata_keys",
"scope": "roundtrip",
"value": "{{map(56.metaData; \"key\")}}"
},
"metadata": {
"designer": {
"x": -522,
"y": -1716
},
"restore": {
"expect": {
"scope": {
"label": "One cycle"
}
}
},
"expect": [
{
"name": "name",
"type": "text",
"label": "Variable name",
"required": true
},
{
"name": "scope",
"type": "select",
"label": "Variable lifetime",
"required": true,
"validate": {
"enum": [
"roundtrip",
"execution"
]
}
},
{
"name": "value",
"type": "any",
"label": "Variable value"
}
],
"interface": [
{
"name": "metadata_keys",
"label": "metadata_keys",
"type": "any"
}
]
}
}
]
}
],
"metadata": {
"version": 1
}
}
samliew – request private consultation
2 Likes
Smart solutions, thanks. I was not aware of the array operators, so I also got a solution with get() and map() but this is much easier.