Skip to content

Commit 26d6f8a

Browse files
committed
remove tutorial comments
1 parent 8fd7f1c commit 26d6f8a

File tree

1 file changed

+0
-6
lines changed
  • sample-apps/discounts/extensions/product-discount/src

1 file changed

+0
-6
lines changed

sample-apps/discounts/extensions/product-discount/src/main.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,11 @@ use shopify_function::Result;
33

44
use serde::{Deserialize, Serialize};
55

6-
// Use the shopify_function crate to generate structs for the function input and output
76
generate_types!(
87
query_path = "./input.graphql",
98
schema_path = "./schema.graphql"
109
);
1110

12-
// Create a structure that matches the JSON structure that you'll use for your configuration
1311
#[derive(Serialize, Deserialize, PartialEq)]
1412
#[serde(rename_all(deserialize = "camelCase"))]
1513
struct Configuration {
@@ -21,7 +19,6 @@ impl Configuration {
2119
const DEFAULT_QUANTITY: i64 = 999;
2220
const DEFAULT_PERCENTAGE: f64 = 0.0;
2321

24-
// Parse the JSON metafield value using serde
2522
fn from_str(value: &str) -> Self {
2623
serde_json::from_str(value).expect("Unable to parse configuration value from metafield")
2724
}
@@ -43,7 +40,6 @@ fn function(input: input::ResponseData) -> Result<output::FunctionResult> {
4340
discount_application_strategy: output::DiscountApplicationStrategy::FIRST,
4441
};
4542

46-
// Get the configuration from the metafield on your function owner
4743
let config = match input.discount_node.metafield {
4844
Some(input::InputDiscountNodeMetafield { value }) =>
4945
Configuration::from_str(&value),
@@ -52,7 +48,6 @@ fn function(input: input::ResponseData) -> Result<output::FunctionResult> {
5248

5349
let targets = input.cart.lines
5450
.iter()
55-
// Use the configured quantity instead of a hardcoded value
5651
.filter(|line| line.quantity >= config.quantity)
5752
.filter_map(|line| match &line.merchandise {
5853
input::InputCartLinesMerchandise::ProductVariant(variant) => Some(variant),
@@ -75,7 +70,6 @@ fn function(input: input::ResponseData) -> Result<output::FunctionResult> {
7570
discounts: vec![output::Discount {
7671
message: None,
7772
targets,
78-
// Use the configured percentage instead of a hardcoded value
7973
value: output::Value {
8074
fixed_amount: None,
8175
percentage: Some(output::Percentage {

0 commit comments

Comments
 (0)