@@ -6,8 +6,8 @@ use shopify_function::Result;
6
6
schema_path = "schema.graphql"
7
7
) ]
8
8
fn cart_lines_discounts_generate_run (
9
- input : cart_lines_discounts_generate_run :: input:: ResponseData ,
10
- ) -> Result < cart_lines_discounts_generate_run :: output:: CartLinesDiscountsGenerateRunResult > {
9
+ input : input:: ResponseData ,
10
+ ) -> Result < output:: CartLinesDiscountsGenerateRunResult > {
11
11
let max_cart_line = input
12
12
. cart
13
13
. lines
@@ -24,35 +24,31 @@ fn cart_lines_discounts_generate_run(
24
24
let has_order_discount_class = input
25
25
. discount
26
26
. discount_classes
27
- . contains ( & cart_lines_discounts_generate_run :: input:: DiscountClass :: ORDER ) ;
27
+ . contains ( & input:: DiscountClass :: ORDER ) ;
28
28
let has_product_discount_class = input
29
29
. discount
30
30
. discount_classes
31
- . contains ( & cart_lines_discounts_generate_run :: input:: DiscountClass :: PRODUCT ) ;
31
+ . contains ( & input:: DiscountClass :: PRODUCT ) ;
32
32
33
33
if !has_order_discount_class && !has_product_discount_class {
34
- return Ok (
35
- cart_lines_discounts_generate_run:: output:: CartLinesDiscountsGenerateRunResult {
36
- operations : vec ! [ ] ,
37
- } ,
38
- ) ;
34
+ return Ok ( output:: CartLinesDiscountsGenerateRunResult { operations : vec ! [ ] } ) ;
39
35
}
40
36
41
37
let mut operations = vec ! [ ] ;
42
38
43
39
// Check if the discount has the ORDER class
44
40
if has_order_discount_class {
45
- operations. push ( cart_lines_discounts_generate_run :: output:: CartOperation :: OrderDiscountsAdd (
46
- cart_lines_discounts_generate_run :: output:: OrderDiscountsAddOperation {
47
- selection_strategy : cart_lines_discounts_generate_run :: output:: OrderDiscountSelectionStrategy :: FIRST ,
48
- candidates : vec ! [ cart_lines_discounts_generate_run :: output:: OrderDiscountCandidate {
49
- targets: vec![ cart_lines_discounts_generate_run :: output:: OrderDiscountCandidateTarget :: OrderSubtotal (
50
- cart_lines_discounts_generate_run :: output:: OrderSubtotalTarget {
41
+ operations. push ( output:: CartOperation :: OrderDiscountsAdd (
42
+ output:: OrderDiscountsAddOperation {
43
+ selection_strategy : output:: OrderDiscountSelectionStrategy :: FIRST ,
44
+ candidates : vec ! [ output:: OrderDiscountCandidate {
45
+ targets: vec![ output:: OrderDiscountCandidateTarget :: OrderSubtotal (
46
+ output:: OrderSubtotalTarget {
51
47
excluded_cart_line_ids: vec![ ] ,
52
48
} ,
53
49
) ] ,
54
50
message: Some ( "10% OFF ORDER" . to_string( ) ) ,
55
- value: cart_lines_discounts_generate_run :: output:: OrderDiscountCandidateValue :: Percentage ( cart_lines_discounts_generate_run :: output:: Percentage {
51
+ value: output:: OrderDiscountCandidateValue :: Percentage ( output:: Percentage {
56
52
value: Decimal ( 10.0 ) ,
57
53
} ) ,
58
54
conditions: None ,
@@ -64,16 +60,18 @@ fn cart_lines_discounts_generate_run(
64
60
65
61
// Check if the discount has the PRODUCT class
66
62
if has_product_discount_class {
67
- operations. push ( cart_lines_discounts_generate_run:: output:: CartOperation :: ProductDiscountsAdd (
68
- cart_lines_discounts_generate_run:: output:: ProductDiscountsAddOperation {
69
- selection_strategy : cart_lines_discounts_generate_run:: output:: ProductDiscountSelectionStrategy :: FIRST ,
70
- candidates : vec ! [ cart_lines_discounts_generate_run:: output:: ProductDiscountCandidate {
71
- targets: vec![ cart_lines_discounts_generate_run:: output:: ProductDiscountCandidateTarget :: CartLine ( cart_lines_discounts_generate_run:: output:: CartLineTarget {
72
- id: max_cart_line. id. clone( ) ,
73
- quantity: None ,
74
- } ) ] ,
63
+ operations. push ( output:: CartOperation :: ProductDiscountsAdd (
64
+ output:: ProductDiscountsAddOperation {
65
+ selection_strategy : output:: ProductDiscountSelectionStrategy :: FIRST ,
66
+ candidates : vec ! [ output:: ProductDiscountCandidate {
67
+ targets: vec![ output:: ProductDiscountCandidateTarget :: CartLine (
68
+ output:: CartLineTarget {
69
+ id: max_cart_line. id. clone( ) ,
70
+ quantity: None ,
71
+ } ,
72
+ ) ] ,
75
73
message: Some ( "20% OFF PRODUCT" . to_string( ) ) ,
76
- value: cart_lines_discounts_generate_run :: output:: ProductDiscountCandidateValue :: Percentage ( cart_lines_discounts_generate_run :: output:: Percentage {
74
+ value: output:: ProductDiscountCandidateValue :: Percentage ( output:: Percentage {
77
75
value: Decimal ( 20.0 ) ,
78
76
} ) ,
79
77
associated_discount_code: None ,
@@ -82,9 +80,5 @@ fn cart_lines_discounts_generate_run(
82
80
) ) ;
83
81
}
84
82
85
- Ok (
86
- cart_lines_discounts_generate_run:: output:: CartLinesDiscountsGenerateRunResult {
87
- operations,
88
- } ,
89
- )
83
+ Ok ( output:: CartLinesDiscountsGenerateRunResult { operations } )
90
84
}
0 commit comments