Skip to content

Commit 09260cd

Browse files
committed
tweaks for the first new discount tutorial
1 parent 71bce0d commit 09260cd

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,18 @@ fn function(input: input::ResponseData) -> Result<output::FunctionResult> {
3737
.collect::<Vec<output::Target>>();
3838

3939
if targets.is_empty() {
40+
// You can use STDERR for debug logs in your function
41+
eprintln!("No cart lines qualify for volume discount.");
4042
return Ok(no_discount);
4143
}
4244

4345
// The shopify_function crate serializes your function result and writes it to STDOUT
4446
Ok(output::FunctionResult {
4547
discounts: vec![output::Discount {
4648
message: None,
49+
// Apply the discount to the collected targets
4750
targets,
51+
// Define a percentage-based discount
4852
value: output::Value {
4953
fixed_amount: None,
5054
percentage: Some(output::Percentage {
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# This file stores configurations for your Shopify app.
22

3-
scopes = "write_products"
3+
scopes = "write_products, write_discounts"

0 commit comments

Comments
 (0)