MCPcopy Create free account
hub / github.com/Shopify/function-examples / run

Function run

checkout/rust/cart-checkout-validation/default/src/run.rs:11–27  ·  view source on GitHub ↗
(input: input::ResponseData)

Source from the content-addressed store, hash-verified

9
10#[shopify_function_target(query_path = "src/run.graphql", schema_path = "schema.graphql")]
11fn run(input: input::ResponseData) -> Result<output::FunctionRunResult> {
12 let mut errors = Vec::new();
13
14 if input
15 .cart
16 .lines
17 .iter()
18 .map(|line| line.quantity)
19 .any(|quantity| quantity > 1)
20 {
21 errors.push(output::FunctionError {
22 localized_message: "Not possible to order more than one of each".to_owned(),
23 target: "$.cart".to_owned(),
24 })
25 }
26 Ok(output::FunctionRunResult { errors })
27}
28
29#[cfg(test)]
30mod tests {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected