Configure complex calculation in Manifest
How-to Guide
Author:
Fluent Commerce
Changed on:
13 Dec 2023
Key Points
- This article describes how to configure complex calculation in Manifest
- Target audience: Architect, Partner Developer, Partner BA.
Author:
Fluent Commerce
Changed on:
13 Dec 2023
| Name | Example | Additional information |
| currency | `{{ currency 123 'AUD' }}` | |
| add | `{{add 1 2}} // 3` | |
| arrayFieldSum | calculation data: const arr = [{age: 1},{age: 2},{age: 3},] `{{arrayFieldSum arr 'age'}} // 6` |
|
1query (
2 $id: ID!
3 $items_after: String
4 $items_first: Int
5 $fulfilmentChoices_first: Int
6) {
7 orderById(id: $id) {
8 id
9 items(after: $items_after, first: $items_first) {
10 edges {
11 node {
12 id
13 price
14 quantity
15 totalPrice
16 totalTaxPrice
17 taxPrice
18 currency
19 }
20 }
21 }
22 fulfilmentChoices(first: $fulfilmentChoices_first) {
23 edges {
24 node {
25 id
26 fulfilmentPrice
27 currency
28 }
29 }
30 }
31 }
32}1{
2 "component": "fc.card.attribute",
3 "props": {
4 "title": "Title",
5 "width": "half",
6 "dataSource": "orderById",
7 "attributes": [
8 {
9 "label": "Items",
10 "template": "{{currency (arrayFieldSum items.edges 'node.totalPrice') items.edges.0.node.currency}}"
11 },
12 {
13 "label": "Shipping",
14 "template": "{{currency (arrayFieldSum fulfilmentChoices.edges 'node.fulfilmentPrice') fulfilmentChoices.edges.0.node.currency}}"
15 },
16 {
17 "label": "Taxes",
18 "template": "{{currency (arrayFieldSum items.edges 'node.totalTaxPrice') items.edges.0.node.currency}}"
19 },
20 {
21 "label": "Total",
22 "template": "{{bold (currency (add (arrayFieldSum items.edges 'node.totalPrice') (add (arrayFieldSum fulfilmentChoices.edges 'node.fulfilmentPrice') (arrayFieldSum items.edges 'node.totalTaxPrice'))) items.edges.0.node.currency ) }}"
23 }
24 ]
25 }
26}