Orders associated with a specific promotion
How to use the Metrics API to get the total number of orders that triggered a specific promotion
The problem
The solution
Query
Key
Value
Filter
Attribute
Operator
Example
curl -g -X POST \
'https://{{your_domain}}.commercelayer.io/metrics/orders/stats' \
-H 'Accept: application/vnd.api.v1+json' \
-H 'Content-Type: application/vnd.api+json' \
-H 'Authorization: Bearer {{your_access_token}}' \
-d '{
"stats": {
"field": "order.id",
"operator": "value_count"
},
"filter": {
"order": {
"date_from": "2021-01-01T00:00:00Z",
"date_to": "2021-12-31T23:59:00Z",
"date_field": "placed_at"
},
"line_items": {
"types": {
"in": [ "percentage_discount_promotions" ]
},
"names": {
"in": [ "Percentage 50" ]
}
}
}
}'Similar cases
Last updated