Skip to content

Commit 31b367c

Browse files
committed
fix formatting
1 parent 6d3123f commit 31b367c

File tree

1 file changed

+11
-14
lines changed
  • sample-apps/bundles-price-per-component/extensions/price-per-component-rs/src

1 file changed

+11
-14
lines changed

sample-apps/bundles-price-per-component/extensions/price-per-component-rs/src/run.rs

Lines changed: 11 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,37 +7,31 @@ use run::output::ExpandedItemFixedPricePerUnitAdjustment;
77
use run::output::ExpandedItemPriceAdjustment;
88
use run::output::ExpandedItemPriceAdjustmentValue;
99

10+
use serde_json::Value;
1011
use shopify_function::prelude::*;
1112
use shopify_function::Result;
12-
use serde_json::Value;
13+
1314

1415
#[shopify_function_target(query_path = "src/run.graphql", schema_path = "schema.graphql")]
1516
fn run(input: input::ResponseData) -> Result<output::FunctionRunResult> {
1617
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);
2120

2221
Ok(output::FunctionRunResult {
2322
operations: cart_operations,
2423
})
2524
}
2625

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> {
3127
cart.lines
3228
.iter()
3329
.filter_map(|line| {
3430
if let ProductVariant(variant) = &line.merchandise {
3531
if let Some(bundle_data) = &variant.product.bundled_component_data {
3632
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);
4135

4236
if !expanded_items.is_empty() {
4337
let expand_operation = ExpandOperation {
@@ -73,7 +67,10 @@ fn create_expanded_items(
7367
.filter_map(|component| {
7468
let id = component.get("id")?.as_str()?;
7569
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);
7774

7875
let price_float = price.parse::<f64>().ok()?;
7976
let adjusted_price = price_float * presentment_currency_rate;

0 commit comments

Comments
 (0)