Categories
CMS Mastering Development

Freeform form throws error on submitting hidden field with JSON

I’ve been running into a strange error with the Freeform plugin. I have made a form that has a hidden input field which gets occupied with JSON. This JSON data then is decoded in the e-mail notification for correct displaying. A little more info for clarification: The user can select multiple products from different product […]

Categories
Mastering Development

Merging items of array of object if they have equal keys

Array of objects that I got [ { "id": 1, "price": 100 }, { "id": 1, "price": 80 }, { "id": 2, "price": 8 }, { "id": 1, "price": 85 } ] Array of objects that I am trying to do [ { "id": 1, "price": 88.33 // AVERAGE VALUE BETWEEN DUPLICATED OBJECTS }, { […]

Categories
Development

Applying different multiplier to an integer depending on threshold

I’m having to build a program which calculates the Annual cost of minutes used for phone providers and it depends on different rates. As an example one phone operator may have the following rates: “rates”: [ {“price”: 15.5, “threshold”: 150}, {“price”: 12.3, “threshold”: 100}, {“price”: 8} ], operators can have multiple tariffs with the last […]

Categories
Development

Elasticsearch filter on aggregation result (for search and aggregation)

Part of this question is related to : Elasticsearch filter on aggregation Context Let’s say my Elasticsearch index contains some orders. Each order has one field price and one field amount. This result in an index that look like this : [ { “docKey”: “order01”, “user”: “1”, “price”: 8, “amount”: 20 }, { “docKey”: “order02”, […]