Skip to content

Commit 73c2971

Browse files
committed
return empty op instead of throw
1 parent 94df3ff commit 73c2971

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

functions-discount-js/src/cart_delivery_options_discounts_generate_run.liquid

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import {
1717
export function cartDeliveryOptionsDiscountsGenerateRun(input) {
1818
const firstDeliveryGroup = input.cart.deliveryGroups[0];
1919
if (!firstDeliveryGroup) {
20-
throw new Error("No delivery groups found");
20+
return {operations: []};
2121
}
2222

2323
const hasShippingDiscountClass = input.discount.discountClasses.includes(
@@ -68,7 +68,7 @@ export function cartDeliveryOptionsDiscountsGenerateRun(
6868
): CartDeliveryOptionsDiscountsGenerateRunResult {
6969
const firstDeliveryGroup = input.cart.deliveryGroups[0];
7070
if (!firstDeliveryGroup) {
71-
throw new Error("No delivery groups found");
71+
return {operations: []};
7272
}
7373

7474
const hasShippingDiscountClass = input.discount.discountClasses.includes(

functions-discount-js/src/cart_lines_discounts_generate_run.liquid

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818

1919
export function cartLinesDiscountsGenerateRun(input) {
2020
if (!input.cart.lines.length) {
21-
throw new Error('No cart lines found');
21+
return {operations: []};
2222
}
2323

2424
const hasOrderDiscountClass = input.discount.discountClasses.includes(
@@ -110,7 +110,7 @@ export function cartLinesDiscountsGenerateRun(
110110
input: CartInput,
111111
): CartLinesDiscountsGenerateRunResult {
112112
if (!input.cart.lines.length) {
113-
throw new Error('No cart lines found');
113+
return {operations: []};
114114
}
115115

116116
const hasOrderDiscountClass = input.discount.discountClasses.includes(
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"payload": {
3+
"export": "cart-lines-discounts-generate-run",
4+
"target": "cart.lines.discounts.generate.run",
5+
"input": {
6+
"cart": {
7+
"lines": []
8+
},
9+
"discount": {
10+
"discountClasses": ["ORDER", "PRODUCT"]
11+
}
12+
},
13+
"output": {
14+
"operations": []
15+
}
16+
}
17+
}

0 commit comments

Comments
 (0)