@@ -7,37 +7,31 @@ use run::output::ExpandedItemFixedPricePerUnitAdjustment;
7
7
use run:: output:: ExpandedItemPriceAdjustment ;
8
8
use run:: output:: ExpandedItemPriceAdjustmentValue ;
9
9
10
+ use serde_json:: Value ;
10
11
use shopify_function:: prelude:: * ;
11
12
use shopify_function:: Result ;
12
- use serde_json :: Value ;
13
+
13
14
14
15
#[ shopify_function_target( query_path = "src/run.graphql" , schema_path = "schema.graphql" ) ]
15
16
fn run ( input : input:: ResponseData ) -> Result < output:: FunctionRunResult > {
16
17
let presentment_currency_rate_f64 = input. presentment_currency_rate . 0 ;
17
- let cart_operations: Vec < CartOperation > = get_update_cart_operations (
18
- & input. cart ,
19
- presentment_currency_rate_f64,
20
- ) ;
18
+ let cart_operations: Vec < CartOperation > =
19
+ get_update_cart_operations ( & input. cart , presentment_currency_rate_f64) ;
21
20
22
21
Ok ( output:: FunctionRunResult {
23
22
operations : cart_operations,
24
23
} )
25
24
}
26
25
27
- fn get_update_cart_operations (
28
- cart : & Cart ,
29
- presentment_currency_rate : f64 ,
30
- ) -> Vec < CartOperation > {
26
+ fn get_update_cart_operations ( cart : & Cart , presentment_currency_rate : f64 ) -> Vec < CartOperation > {
31
27
cart. lines
32
28
. iter ( )
33
29
. filter_map ( |line| {
34
30
if let ProductVariant ( variant) = & line. merchandise {
35
31
if let Some ( bundle_data) = & variant. product . bundled_component_data {
36
32
if let Some ( components) = parse_bundle_components ( & bundle_data. value ) {
37
- let expanded_items = create_expanded_items (
38
- components,
39
- presentment_currency_rate,
40
- ) ;
33
+ let expanded_items =
34
+ create_expanded_items ( components, presentment_currency_rate) ;
41
35
42
36
if !expanded_items. is_empty ( ) {
43
37
let expand_operation = ExpandOperation {
@@ -73,7 +67,10 @@ fn create_expanded_items(
73
67
. filter_map ( |component| {
74
68
let id = component. get ( "id" ) ?. as_str ( ) ?;
75
69
let price = component. get ( "price" ) ?. as_str ( ) ?;
76
- let quantity = component. get ( "quantity" ) . and_then ( |q| q. as_u64 ( ) ) . unwrap_or ( 1 ) ;
70
+ let quantity = component
71
+ . get ( "quantity" )
72
+ . and_then ( |q| q. as_u64 ( ) )
73
+ . unwrap_or ( 1 ) ;
77
74
78
75
let price_float = price. parse :: < f64 > ( ) . ok ( ) ?;
79
76
let adjusted_price = price_float * presentment_currency_rate;
0 commit comments