Hello everyone,
Problem
{
"products":[
(object),
(object)
]
}
{
"prices":[
(object),
(object)
]
}
Solution
{
"products":[
{
...
...
(pricesObject1)
},
{
...
...
(pricesObject2)
}
]
}
Roland
March 20, 2023, 3:38pm
2
Your post is not entirely clear to me, but it reminds me of a shared configuration.
Maybe this configuration uses some tactics that you need?
Hi we’ve build this configuration to show how a calculation could be done with volume discounts, customer discount and using data is separate arrays.
Information
Last updated: 2023-02-01
Alumio version: 3.25.0
Advice: Use the datapoints to see what a transformer has done.
Features
Testdata
Transformers for calculations
Needed calculation
This calculation example will calculate prices with volume discount and user discount. The origin data contains three objects.
Order: contains the order …
Let me rephrase then
I possess the following object and need to remove any elements(wProductVariations.attributes ) from wProductVariations that do not match the attributes object at the root level:
{
"attributes": [
{
"id": 1,
"option": "SMALL"
},
{
"id": 2,
"option": "White"
}
],
"wProductVariations": [
{
"id": 2237,
"attributes": [
{
"id": 1,
"option": "XX-Large"
},
{
"id": 2,
"option": "White"
}
],
"menu_order": 0,
"meta_data": [
{
"id": 56685,
"key": "_wc_additional_variation_images",
"value": ""
}
]
},
{
"id": 2236,
"attributes": [
{
"id": 1,
"option": "X-Large"
},
{
"id": 2,
"option": "White"
}
]
},
{
"id": 2235,
"attributes": [
{
"id": 1,
"option": "Large"
},
{
"id": 2,
"option": "White"
}
]
},
{
"id": 2234,
"attributes": [
{
"id": 1,
"option": "Medium"
},
{
"id": 2,
"option": "White"
}
]
},
{
"id": 2233,
"attributes": [
{
"id": 1,
"option": "Small"
},
{
"id": 2,
"option": "White"
}
]
}
]
}
hope this is clear now? Thanks in advance
Roland
March 21, 2023, 12:50pm
4
@Alumio_support
I-am a bit busy, seems like it can be done with JMESpath perhaps?
Could you help out?
alright i will check it out
Gugi
March 21, 2023, 4:59pm
6
Hi @abubakar
You can recursively copy the root level’s attributes
object into all the objects of wProductVariantions
array as match_attributes
. Then you can use the below JMESPath to filter out all objects that do not match the attributes object copied inside each wProductVariants
objects.
&{wProductVariations[?attributes == match_attributes]}
Please give it a try and let us know if you have any questions.
1 Like
Thanks @Gugi and @Roland , this solution works fine