Skip to content

Commit 0c1a210

Browse files
committed
add better logs for discount (multi target)
1 parent fb88af2 commit 0c1a210

File tree

4 files changed

+101
-10
lines changed

4 files changed

+101
-10
lines changed

functions-discount-js/tests/fixtures/log.json renamed to functions-discount-js/tests/fixtures/cart-lines-discount-generate-log.json

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
"cart": {
77
"lines": [
88
{
9-
"id": "gid://shopify/CartLine/1",
9+
"id": "gid://shopify/CartLine/0",
1010
"cost": {
1111
"subtotalAmount": {
12-
"amount": "100.0"
12+
"amount": "6.0"
1313
}
1414
}
1515
}
1616
]
1717
},
1818
"discount": {
19-
"discountClasses": ["ORDER", "PRODUCT"]
19+
"discountClasses": ["PRODUCT", "ORDER", "SHIPPING"]
2020
}
2121
},
22+
"inputBytes": 126,
2223
"output": {
2324
"operations": [
2425
{
@@ -35,7 +36,7 @@
3536
],
3637
"value": {
3738
"percentage": {
38-
"value": 10
39+
"value": 10.0
3940
}
4041
}
4142
}
@@ -51,13 +52,13 @@
5152
"targets": [
5253
{
5354
"cartLine": {
54-
"id": "gid://shopify/CartLine/1"
55+
"id": "gid://shopify/CartLine/0"
5556
}
5657
}
5758
],
5859
"value": {
5960
"percentage": {
60-
"value": 20
61+
"value": 20.0
6162
}
6263
}
6364
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"payload": {
3+
"export": "cart-delivery-options-discounts-generate-run",
4+
"target": "cart.delivery-options.discounts.generate.run",
5+
"input": {
6+
"discount": {
7+
"discountClasses": ["SHIPPING"]
8+
},
9+
"cart": {
10+
"deliveryGroups": [
11+
{
12+
"id": "gid://shopify/CartDeliveryGroup/1"
13+
}
14+
]
15+
}
16+
},
17+
"output": {
18+
"operations": [
19+
{
20+
"deliveryDiscountsAdd": {
21+
"candidates": [
22+
{
23+
"message": "FREE DELIVERY",
24+
"targets": [
25+
{
26+
"deliveryGroup": {
27+
"id": "gid://shopify/CartDeliveryGroup/1"
28+
}
29+
}
30+
],
31+
"value": {
32+
"percentage": {
33+
"value": 100.0
34+
}
35+
}
36+
}
37+
],
38+
"selectionStrategy": "ALL"
39+
}
40+
}
41+
]
42+
}
43+
}
44+
}

functions-discount-rs/tests/fixtures/log.json renamed to functions-discount-rs/tests/fixtures/cart-lines-discount-generate-log.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,20 @@
66
"cart": {
77
"lines": [
88
{
9-
"id": "gid://shopify/CartLine/1",
9+
"id": "gid://shopify/CartLine/0",
1010
"cost": {
1111
"subtotalAmount": {
12-
"amount": "100.0"
12+
"amount": "6.0"
1313
}
1414
}
1515
}
1616
]
1717
},
1818
"discount": {
19-
"discountClasses": ["ORDER", "PRODUCT"]
19+
"discountClasses": ["PRODUCT", "ORDER", "SHIPPING"]
2020
}
2121
},
22+
"inputBytes": 126,
2223
"output": {
2324
"operations": [
2425
{
@@ -54,7 +55,7 @@
5455
"targets": [
5556
{
5657
"cartLine": {
57-
"id": "gid://shopify/CartLine/1",
58+
"id": "gid://shopify/CartLine/0",
5859
"quantity": null
5960
}
6061
}
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
{
2+
"payload": {
3+
"export": "cart_delivery_options_discounts_generate_run",
4+
"target": "cart.delivery-options.discounts.generate.run",
5+
"input": {
6+
"discount": {
7+
"discountClasses": ["SHIPPING"]
8+
},
9+
"cart": {
10+
"deliveryGroups": [
11+
{
12+
"id": "gid://shopify/CartDeliveryGroup/1"
13+
}
14+
]
15+
}
16+
},
17+
"output": {
18+
"operations": [
19+
{
20+
"deliveryDiscountsAdd": {
21+
"candidates": [
22+
{
23+
"associatedDiscountCode": null,
24+
"message": "FREE DELIVERY",
25+
"targets": [
26+
{
27+
"deliveryGroup": {
28+
"id": "gid://shopify/CartDeliveryGroup/1"
29+
}
30+
}
31+
],
32+
"value": {
33+
"percentage": {
34+
"value": "100.0"
35+
}
36+
}
37+
}
38+
],
39+
"selectionStrategy": "ALL"
40+
}
41+
}
42+
]
43+
}
44+
}
45+
}

0 commit comments

Comments
 (0)