### Example Output JSON for Delivery Discount (Rust) Source: https://shopify.dev/docs/api/functions/latest/discount An example of the JSON output structure for a delivery discount generated in Rust, showing a fixed amount discount. ```rust { "operations": [ { "deliveryDiscountsAdd": { "candidates": [ { "associatedDiscountCode": null, "message": "Free Shipping", "targets": [ { "deliveryOption": { "handle": "standard-shipping" } }, { "deliveryOption": { "handle": "express-shipping" } } ], "value": { "fixedAmount": { "amount": "0.0" } } } ], "selectionStrategy": "ALL" } } ] } ``` -------------------------------- ### Example Output JSON (Rust) Source: https://shopify.dev/docs/api/functions/latest/discount Example JSON output demonstrating the structure of a product discount operation for cart lines, including selection strategy and candidate discounts. ```JSON { "operations": [ { "productDiscountsAdd": { "selectionStrategy": "FIRST", "candidates": [ { "message": "10% VIP discount!", "targets": [ { "cartLine": { "id": "gid://shopify/CartLine/1", "quantity": null } } ], "value": { "percentage": { "value": "10.0" } } } ] } } ] } ``` -------------------------------- ### Example Output JSON for Delivery Discount (JavaScript) Source: https://shopify.dev/docs/api/functions/latest/discount An example of the JSON output structure for a delivery discount generated in JavaScript, showing a percentage discount. ```javascript { "operations": [ { "deliveryDiscountsAdd": { "candidates": [ { "message": "Free Shipping", "targets": [ { "deliveryOption": { "handle": "standard-shipping" } }, { "deliveryOption": { "handle": "express-shipping" } } ], "value": { "percentage": { "value": 100 } } } ], "selectionStrategy": "ALL" } } ] } ``` -------------------------------- ### Rust Function Output Example Source: https://shopify.dev/docs/api/functions/latest/product-discount Example JSON output for the Rust function, showing a 10% discount applied to a specific cart line. ```json { "discountApplicationStrategy": "FIRST", "discounts": [ { "message": "10% off already discounted items", "targets": [ { "cartLine": { "id": "gid://shopify/CartLine/1", "quantity": 1 } } ], "value": { "percentage": { "value": "10.0" } } } ] } ``` -------------------------------- ### Add Order Discount (JavaScript) Source: https://shopify.dev/docs/api/functions/latest/discount Example of adding a 10% discount to an entire order. ```javascript { "operations": [ { "orderDiscountsAdd": { "candidates": [ { "message": "10% OFF ORDER", "targets": [ { "orderSubtotal": { "excludedCartLineIds": [] } } ], "value": { "percentage": { "value": "10.0" } } } ], "selectionStrategy": "FIRST" } }, { "productDiscountsAdd": { "candidates": [ { "message": "20% OFF PRODUCT", "targets": [ { "cartLine": { "id": "gid://shopify/CartLine/0" } } ], "value": { "percentage": { "value": "20.0" } } } ], "selectionStrategy": "FIRST" } } ] } ``` -------------------------------- ### Order Discount Output JSON Source: https://shopify.dev/docs/api/functions/latest/order-discount Example JSON output for an order discount, showing the discount strategy and applied discount details. ```json { "discountApplicationStrategy": "FIRST", "discounts": [ { "conditions": null, "message": "10% off your order!", "targets": [ { "orderSubtotal": { "excludedVariantIds": [] } } ], "value": { "percentage": { "value": "10.0" } } } ] } ``` ```json { "discountApplicationStrategy": "FIRST", "discounts": [ { "message": "10% off your order!", "targets": [ { "orderSubtotal": { "excludedVariantIds": [] } } ], "value": { "percentage": { "value": "10.0" } } } ] } ``` -------------------------------- ### Input Object for Fetching Discounts (Rust) Source: https://shopify.dev/docs/api/functions/latest/discount Example input object in Rust for fetching discounts, including discount codes and buyer email. ```rust { "enteredDiscountCodes": [{"code": "SUMMER10"}, {"code": "WELCOME20"}], "cart": { "buyerIdentity": { "email": "customer@example.com" } } } ``` -------------------------------- ### Generate Discount Input Object (Rust) Source: https://shopify.dev/docs/api/functions/latest/discount Example input object in Rust for a discount function, showing a cart with a custom product. ```json { "cart": { "lines": [ { "id": "gid://shopify/CartLine/0", "merchandise": { "__typename": "ProductVariant", "product": { "metafield": { "value": "true" } } } } ] }, "discount": { "discountClasses": [ "PRODUCT" ] } } ``` -------------------------------- ### Product and Order Discounts (Rust) Source: https://shopify.dev/docs/api/functions/latest/discount Demonstrates how to add product and order discounts using Rust. Includes accepting discount codes and applying percentage-based discounts. ```json { "operations": [ { "enteredDiscountCodesAccept": { "codes": [ { "code": "SUMMER10" } ] } }, { "productDiscountsAdd": { "candidates": [ { "associatedDiscountCode": null, "message": "10% off with SUMMER10 code", "targets": [ { "cartLine": { "id": "gid://shopify/CartLine/123", "quantity": null } } ], "value": { "percentage": { "value": "10.0" } } } ], "selectionStrategy": "FIRST" } }, { "orderDiscountsAdd": { "candidates": [ { "associatedDiscountCode": null, "conditions": null, "message": "15% off entire order", "targets": [ { "orderSubtotal": { "excludedCartLineIds": [] } } ], "value": { "percentage": { "value": "15.0" } } } ], "selectionStrategy": "MAXIMUM" } } ] } ``` -------------------------------- ### Example Output JSON (Rust) Source: https://shopify.dev/docs/api/functions/latest/delivery-customization This is an example of the JSON output produced by the Rust function for delivery option renaming. ```json { "operations": [ { "deliveryOptionRename": { "deliveryOptionHandle": "standard_shipping", "title": "Standard Shipping - May be delayed due to weather conditions" } } ] } ``` -------------------------------- ### Example Input Object (Rust) Source: https://shopify.dev/docs/api/functions/latest/order-routing-location-rule This is an example of the input object structure for the location ranking function, formatted for Rust. ```json { "fulfillmentGroups": [ { "handle": "1", "inventoryLocationHandles": [ "91260846373", "91260879141" ], "deliveryAddress": { "provinceCode": "ON" } } ], "locations": [ { "handle": "91260846373", "address": { "countryCode": "CA", "provinceCode": "ON" } }, { "handle": "91260879141", "address": { "countryCode": "CA", "provinceCode": "ON" } } ] } ``` -------------------------------- ### Input Object for Product Discount Configuration (JavaScript) Source: https://shopify.dev/docs/api/functions/latest/discount Example input object for configuring product discounts in JavaScript, specifying percentage and target variant IDs. ```json { "cart": { "lines": [ { "id": "gid://shopify/CartLine/1", "quantity": 2, "merchandise": { "__typename": "ProductVariant", "id": "gid://shopify/ProductVariant/123456", "title": "Blue T-Shirt" } } ] }, "discount": { "metafield": { "jsonValue": { "percentage": 15.0, "target_variant_ids": ["gid://shopify/ProductVariant/123456"] } } } } ``` -------------------------------- ### Example Output JSON (Rust) Source: https://shopify.dev/docs/api/functions/latest/order-routing-location-rule This is an example of the JSON output generated by the location ranking function, formatted for Rust. ```json { "operations": [ { "fulfillmentGroupLocationRankingAdd": { "fulfillmentGroupHandle": "1", "rankings": [ { "locationHandle": "75667898613", "rank": 0 }, { "locationHandle": "66494595317", "rank": 1 } ] } } ] } ``` -------------------------------- ### Example Output JSON (Rust) Source: https://shopify.dev/docs/api/functions/latest/discount Illustrates the JSON output structure for delivery discounts generated by a Rust function, showing fixed amount discounts. ```json { "operations": [ { "deliveryDiscountsAdd": { "selectionStrategy": "ALL", "candidates": [ { "message": "Free shipping for members", "targets": [ { "deliveryOption": { "handle": "cae179072e1b0a565f51700b666b62c5-b514e01af8655a9229f7a04405396118" } } ], "value": { "fixedAmount": { "amount": "1.0" } } }, { "message": "$5 off shipping for members", "targets": [ { "deliveryOption": { "handle": "cae179072e1b0a565f51700b666b62c5-fbcaff8dd39a68820109eb990460be0a" } } ], "value": { "fixedAmount": { "amount": "5.0" } } } ] } } ] } ``` -------------------------------- ### Example Output JSON for JavaScript Function Source: https://shopify.dev/docs/api/functions/latest/payment-customization This is an example of the JSON output generated by the JavaScript function when hiding payment methods. ```JSON { "operations": [ { "paymentMethodHide": { "paymentMethodId": "gid://shopify/PaymentCustomizationPaymentMethod/1" } } ] } ``` -------------------------------- ### Example Output JSON for Rust Function Source: https://shopify.dev/docs/api/functions/latest/payment-customization This is an example of the JSON output generated by the Rust function when hiding payment methods. ```JSON { "operations": [ { "paymentMethodHide": { "paymentMethodId": "gid://shopify/PaymentCustomizationPaymentMethod/1", "placements": null } } ] } ``` -------------------------------- ### Example Output JSON (JavaScript) Source: https://shopify.dev/docs/api/functions/latest/discount Shows the JSON output for delivery discounts generated by a JavaScript function, including percentage and fixed amount discounts. ```json { "operations": [ { "deliveryDiscountsAdd": { "candidates": [ { "message": "Free shipping for loyal customers!", "targets": [ { "deliveryOption": { "handle": "standard" } } ], "value": { "percentage": { "value": "100.0" } } }, { "message": "$5 off shipping for loyal customers!", "targets": [ { "deliveryOption": { "handle": "express" } } ], "value": { "fixedAmount": { "amount": "5.0" } } } ], "selectionStrategy": "ALL" } } ] } ``` -------------------------------- ### Input Object for Discount Configuration (Rust) Source: https://shopify.dev/docs/api/functions/latest/discount Example input object representing cart details and discount configuration, including product ID and discount amount, formatted for Rust. ```json { "cart": { "lines": [ { "id": "gid://shopify/CartLine/1", "quantity": 3, "merchandise": { "__typename": "ProductVariant", "id": "gid://shopify/ProductVariant/1", "product": { "id": "gid://shopify/Product/1" } } } ] }, "discount": { "metafield": { "jsonValue": { "discount_amount": 10.0, "max_quantity": 2, "product_id": "gid://shopify/Product/1" } } } } ``` -------------------------------- ### Input Object for Discount Configuration (JavaScript) Source: https://shopify.dev/docs/api/functions/latest/discount Example input object representing cart details and discount configuration, including product ID and discount amount, formatted for JavaScript. ```json { "cart": { "lines": [ { "id": "gid://shopify/CartLine/1", "quantity": 3, "merchandise": { "__typename": "ProductVariant", "id": "gid://shopify/ProductVariant/123456", "product": { "id": "gid://shopify/Product/1" } } } ] }, "discount": { "metafield": { "jsonValue": { "discount_amount": 5.0, "max_quantity": 2, "product_id": "gid://shopify/Product/1" } } } } ``` -------------------------------- ### Generate Combined Multi-Type Discounts (Rust) Source: https://shopify.dev/docs/api/functions/latest/discount This example demonstrates generating combined discounts for products, orders, and shipping. It applies a 10% order discount, a 20% discount to the most expensive item, and makes delivery options free. ```rust query Input { cart { lines { id cost { subtotalAmount { amount } } } } discount { discountClasses } } ``` -------------------------------- ### Cart Transform Output JSON Example Source: https://shopify.dev/docs/api/functions/latest/cart-transform Example JSON output for a cart transform operation, showing a line item update with a fixed price adjustment. The 'amount' can be a string or a number depending on the language context. ```json { "operations": [ { "lineUpdate": { "cartLineId": "gid://shopify/CartLine/a8a95ef8-5c64-4052-9939-250ea091bc9c", "image": null, "price": { "adjustment": { "fixedPricePerUnit": { "amount": "579.95" } } }, "title": null } } ] } ``` ```json { "operations": [ { "lineUpdate": { "cartLineId": "gid://shopify/CartLine/a8a95ef8-5c64-4052-9939-250ea091bc9c", "price": { "adjustment": { "fixedPricePerUnit": { "amount": 579.95 } } } } } ] } ``` -------------------------------- ### productDiscountsAdd Source: https://shopify.dev/docs/api/functions/latest/discount Adds product discounts to specific items in the cart. Example: '20% OFF PRODUCT'. ```APIDOC ## productDiscountsAdd ### Description Adds product discounts to specific items in the cart. Example: '20% OFF PRODUCT'. ### Method Not specified, likely part of a mutation or function call. ### Parameters #### Request Body - **candidates** (array) - Required - A list of discount candidates to apply. - **message** (string) - Required - A human-readable message for the discount. - **targets** (array) - Required - Specifies what the discount applies to. - **cartLine** (object) - Required - Applies discount to a specific cart line. - **id** (string) - Required - The ID of the cart line. - **value** (object) - Required - The value of the discount. - **percentage** (object) - Required - A percentage-based discount. - **value** (number) - Required - The percentage value (e.g., 20 for 20%). - **selectionStrategy** (string) - Required - The strategy for selecting which discount to apply (e.g., "FIRST"). ``` -------------------------------- ### Output JSON for Product Discount Generation (Rust) Source: https://shopify.dev/docs/api/functions/latest/discount Example JSON output representing a product discount generated by a Shopify function, formatted for Rust. ```json { "operations": [ { "productDiscountsAdd": { "candidates": [ { "associatedDiscountCode": null, "message": "20% off first item", "targets": [ { "cartLine": { "id": "gid://shopify/CartLine/1", "quantity": null } } ], "value": { "percentage": { "value": "20.0" } } } ], "selectionStrategy": "FIRST" } } ] } ``` -------------------------------- ### Product and Order Discounts (JavaScript) Source: https://shopify.dev/docs/api/functions/latest/discount Shows how to add product and order discounts using JavaScript. Covers accepting discount codes and applying percentage-based discounts. ```json { "operations": [ { "enteredDiscountCodesAccept": { "codes": [ { "code": "SUMMER10" } ] } }, { "productDiscountsAdd": { "candidates": [ { "message": "10% off with SUMMER10 code", "targets": [ { "cartLine": { "id": "gid://shopify/CartLine/123" } } ], "value": { "percentage": { "value": "10.0" } } } ], "selectionStrategy": "FIRST" } }, { "orderDiscountsAdd": { "candidates": [ { "message": "15% off entire order", "targets": [ { "orderSubtotal": { "excludedCartLineIds": [] } } ], "value": { "percentage": { "value": "15.0" } } } ], "selectionStrategy": "MAXIMUM" } } ] } ``` -------------------------------- ### Input Query for Product Discount Configuration (Rust) Source: https://shopify.dev/docs/api/functions/latest/product-discount Fetches cart line details and discount configuration from app metafields. Used for applying amount-off discounts. ```rust query Input { cart { lines { id quantity merchandise { __typename ... on ProductVariant { id title } } } } discountNode { metafield(namespace: "$app:product-discount", key: "function-configuration") { jsonValue } } } ``` -------------------------------- ### Cart Transform Update Operation Example: Overriding cart line item properties for customers with tags Source: https://shopify.dev/docs/api/functions/latest/cart-transform This example demonstrates how to modify the price of items in a cart to apply a discount based on if the customer has a "VIP" tag associated with their account. It shows how to check for customer tags and update item titles and prices accordingly. ```APIDOC ## cart.transform.run ### Description Applies special pricing and labels for VIP customers by checking for the 'VIP' tag and updating cart line items. ### Method POST ### Endpoint /cart/transform ### Parameters #### Request Body - **operations** (array) - Required - An array of operations to perform on the cart. - **lineExpand** (object) - Required - Represents an operation to expand and modify cart line items. - **cartLineId** (string) - Required - The ID of the cart line to modify. - **expandedCartItems** (array) - Required - An array of expanded cart items with modifications. - **merchandiseId** (string) - Required - The ID of the merchandise. - **price** (object) - Optional - The price details for the item. - **adjustment** (object) - Optional - Price adjustment details. - **fixedPricePerUnit** (object) - Optional - Fixed price per unit. - **amount** (string) - Required - The adjusted amount. - **quantity** (integer) - Required - The quantity of the item. ### Request Example ```json { "operations": [ { "lineExpand": { "cartLineId": "1", "expandedCartItems": [ { "merchandiseId": "gid://shopify/ProductVariant/2", "price": { "adjustment": { "fixedPricePerUnit": { "amount": "25.00" } } }, "quantity": 1 }, { "merchandiseId": "gid://shopify/ProductVariant/3", "price": { "adjustment": { "fixedPricePerUnit": { "amount": "25.00" } } }, "quantity": 1 }, { "merchandiseId": "gid://shopify/ProductVariant/4", "price": { "adjustment": { "fixedPricePerUnit": { "amount": "25.00" } } }, "quantity": 1 } ] } } ] } ``` ### Response #### Success Response (200) - **operations** (array) - An array of operations performed on the cart. #### Response Example ```json { "operations": [ { "lineExpand": { "cartLineId": "1", "expandedCartItems": [ { "merchandiseId": "gid://shopify/ProductVariant/2", "price": { "adjustment": { "fixedPricePerUnit": { "amount": "25.00" } } }, "quantity": 1 }, { "merchandiseId": "gid://shopify/ProductVariant/3", "price": { "adjustment": { "fixedPricePerUnit": { "amount": "25.00" } } }, "quantity": 1 }, { "merchandiseId": "gid://shopify/ProductVariant/4", "price": { "adjustment": { "fixedPricePerUnit": { "amount": "25.00" } } }, "quantity": 1 } ] } } ] } ``` ``` ```APIDOC ## cart.transform.run - Input Query (Rust) ### Description This is the input query structure for the `cart.transform.run` operation when using Rust, used to fetch cart details including line items and buyer identity. ### Language Rust ### Code ```rust query Input { cart { lines { id quantity cost { amountPerQuantity { amount } } merchandise { __typename ... on ProductVariant { product { title } } ... on CustomProduct { title } } } buyerIdentity { customer { id hasAnyTag(tags: ["VIP"]) } } } } ``` ``` ```APIDOC ## cart.transform.run - Input Query (JavaScript) ### Description This is the input query structure for the `cart.transform.run` operation when using JavaScript, used to fetch cart details including line items and buyer identity. ### Language JavaScript ### Code ```javascript query Input { cart { lines { id quantity cost { amountPerQuantity { amount } } merchandise { ... on ProductVariant { product { title } } ... on CustomProduct { title } } } buyerIdentity { customer { id hasAnyTag(tags: ["VIP"]) } } } } ``` ``` ```APIDOC ## cart.transform.run - Input Object (Rust) ### Description This is an example input object for the `cart.transform.run` operation when using Rust, illustrating the structure of cart data including lines and buyer identity with VIP tag status. ### Language Rust ### Code ```rust { "cart": { "lines": [ { "id": "gid://shopify/CartLine/6727c32a-9829-445b-8460-71774972fa55", "quantity": 1, "cost": { "amountPerQuantity": { "amount": "749.95" } }, "merchandise": { "__typename": "ProductVariant", "product": { "title": "The Collection Snowboard: Liquid" } } } ], "buyerIdentity": { "customer": { "id": "gid://shopify/Customer/8808655552742", "hasAnyTag": true } } } } ``` ``` -------------------------------- ### Output JSON for Order Review Source: https://shopify.dev/docs/api/functions/latest/payment-customization Example JSON output indicating an order review is required. ```json { "operations": [ { "orderReviewAdd": { "reason": "An order over $5000 requires review." } } ] } ``` -------------------------------- ### Example Discount Output (Rust) Source: https://shopify.dev/docs/api/functions/latest/discount This JSON output represents the generated discount operations, including product discounts and order discounts with their respective values and targets. ```json { "operations": [ { "productDiscountsAdd": { "candidates": [ { "associatedDiscountCode": null, "message": "15% OFF PRODUCT", "targets": [ { "cartLine": { "id": "gid://shopify/CartLine/1", "quantity": null } } ], "value": { "percentage": { "value": "15.0" } } } ], "selectionStrategy": "FIRST" } }, { "orderDiscountsAdd": { "candidates": [ { "associatedDiscountCode": null, "conditions": null, "message": "10% OFF ORDER", "targets": [ { "orderSubtotal": { "excludedCartLineIds": [] } } ], "value": { "percentage": { "value": "10.0" } } } ], "selectionStrategy": "FIRST" } } ] } ``` -------------------------------- ### Input Object Structure (Rust) Source: https://shopify.dev/docs/api/functions/latest/cart-and-checkout-validation Example of the input object structure for cart validation functions in Rust. ```json { "cart": { "deliveryGroups": [ { "deliveryAddress": { "address1": "PO Box 123", "address2": null } } ] } } ``` -------------------------------- ### Output JSON for Product Discount Generation (JavaScript) Source: https://shopify.dev/docs/api/functions/latest/discount Example JSON output representing a product discount generated by a Shopify function, formatted for JavaScript. ```json { "operations": [ { "productDiscountsAdd": { "candidates": [ { "message": "20% off first item", "targets": [ { "cartLine": { "id": "gid://shopify/CartLine/1" } } ], "value": { "percentage": { "value": "20.0" } } } ], "selectionStrategy": "FIRST" } } ] } ``` -------------------------------- ### Add Delivery Discount (JavaScript) Source: https://shopify.dev/docs/api/functions/latest/discount Adds a delivery discount to the cart. This example provides a free delivery discount. ```javascript { "operations": [ { "deliveryDiscountsAdd": { "candidates": [ { "message": "Free delivery when buying X and Y", "targets": [ { "deliveryGroup": { "id": "gid://shopify/CartDeliveryGroup/1" } } ], "value": { "percentage": { "value": 100 } } } ], "selectionStrategy": "ALL" } } ] } ``` -------------------------------- ### Add Delivery Discount (Rust) Source: https://shopify.dev/docs/api/functions/latest/discount Adds a delivery discount to the cart. This example provides a free delivery discount. ```rust { "operations": [ { "deliveryDiscountsAdd": { "candidates": [ { "associatedDiscountCode": null, "message": "Free delivery when buying X and Y", "targets": [ { "deliveryGroup": { "id": "gid://shopify/CartDeliveryGroup/1" } } ], "value": { "percentage": { "value": "100.0" } } } ], "selectionStrategy": "ALL" } } ] } ``` -------------------------------- ### Run Product Discount Function (Rust) Source: https://shopify.dev/docs/api/functions/latest/product-discount Applies a 20% discount to the first item in the cart. Requires the cart object in the input. ```rust query Input { cart { lines { id } } } ``` ```rust { "cart": { "lines": [ { "id": "gid://shopify/CartLine/1", "quantity": 1 } ] } } ``` ```rust use crate::schema; use shopify_function::prelude::*; use shopify_function::Result; #[shopify_function] fn run(input: schema::run::Input) -> Result { let mut discounts = vec![]; let percentage = 20.0; // Check if there are any lines in the cart if let Some(first_line) = input.cart().lines().first() { discounts.push(schema::Discount { value: schema::Value::Percentage(schema::Percentage { value: Decimal(percentage), }), targets: vec![schema::Target::CartLine(schema::CartLineTarget { id: first_line.id().clone(), quantity: None, })], message: Some(format!("{}% off first item", percentage)), }); } Ok(schema::FunctionRunResult { discounts, discount_application_strategy: schema::DiscountApplicationStrategy::First, }) } ``` ```json { "discountApplicationStrategy": "FIRST", "discounts": [ { "message": "20% off first item", "targets": [ { "cartLine": { "id": "gid://shopify/CartLine/1", "quantity": null } } ], "value": { "percentage": { "value": "20.0" } } } ] } ``` -------------------------------- ### Add Order Discount (JavaScript) Source: https://shopify.dev/docs/api/functions/latest/discount Example of adding an order discount with a minimum subtotal condition using JavaScript. ```json { "operations": [ { "orderDiscountsAdd": { "candidates": [ { "conditions": [ { "orderMinimumSubtotal": { "excludedCartLineIds": [], "minimumAmount": "100.0" } } ], "message": "10% off your order", "targets": [ { "orderSubtotal": { "excludedCartLineIds": [] } } ], "value": { "percentage": { "value": "10.0" } } } ], "selectionStrategy": "MAXIMUM" } } ] } ``` -------------------------------- ### Example Delivery Discount Output (JavaScript) Source: https://shopify.dev/docs/api/functions/latest/discount Shows the JSON output for a generated delivery discount, indicating a 15% reduction for the 'standard' shipping option. ```json { "operations": [ { "deliveryDiscountsAdd": { "candidates": [ { "message": "15% off shipping", "targets": [ { "deliveryOption": { "handle": "standard" } } ], "value": { "percentage": { "value": "15.0" } } } ], "selectionStrategy": "ALL" } } ] } ``` -------------------------------- ### Add Order Discount (Rust) Source: https://shopify.dev/docs/api/functions/latest/discount Example of adding an order discount with a minimum subtotal condition using Rust. ```json { "operations": [ { "orderDiscountsAdd": { "candidates": [ { "associatedDiscountCode": null, "conditions": [ { "orderMinimumSubtotal": { "excludedCartLineIds": [], "minimumAmount": "100.0" } } ], "message": "10% off your order", "targets": [ { "orderSubtotal": { "excludedCartLineIds": [] } } ], "value": { "percentage": { "value": "10.0" } } } ], "selectionStrategy": "MAXIMUM" } } ] } ``` -------------------------------- ### Generate Percentage Discount for Specific SKUs (Rust Input Query) Source: https://shopify.dev/docs/api/functions/latest/discount Input query to retrieve cart line details and discount configuration metafields for applying a percentage discount based on SKUs. This example uses Rust. ```graphql query Input { cart { lines { id quantity merchandise { __typename ... on ProductVariant { id sku } } } } discount { metafield(namespace: "$app:product-discount", key: "function-configuration") { jsonValue } } } ``` -------------------------------- ### Input Object for Payment Methods (Rust) Source: https://shopify.dev/docs/api/functions/latest/payment-customization Example input object representing payment methods available to the customer. ```json { "paymentMethods": [ { "id": "gid://shopify/PaymentCustomizationPaymentMethod/0", "name": "(for testing) Bogus Gateway" }, { "id": "gid://shopify/PaymentCustomizationPaymentMethod/1", "name": "Deferred" }, { "id": "gid://shopify/PaymentCustomizationPaymentMethod/2", "name": "Bank Deposit" }, { "id": "gid://shopify/PaymentCustomizationPaymentMethod/3", "name": "Gift card" } ] } ``` -------------------------------- ### Rust Input Object for Product Discount Configuration Source: https://shopify.dev/docs/api/functions/latest/product-discount Example of the input JSON object in Rust, specifying cart line details and discount configuration including percentage. ```json { "cart": { "lines": [ { "id": "gid://shopify/CartLine/1", "quantity": 1, "cost": { "amountPerQuantity": { "amount": "80.00" }, "compareAtAmountPerQuantity": { "amount": "100.00" } } } ] }, "discountNode": { "metafield": { "jsonValue": { "percentage": 10.0 } } } } ``` -------------------------------- ### Output JSON for Order Review Add Source: https://shopify.dev/docs/api/functions/latest/payment-customization Example JSON output for a function that adds an order review requirement. ```json { "operations": [ { "orderReviewAdd": { "reason": "Order placed by company location with less than 10 orders requires review." } } ] } ``` ```json { "operations": [ { "orderReviewAdd": { "reason": "Order placed by company location with less than 10 orders requires review." } } ] } ``` -------------------------------- ### Rust Output JSON for Discount Source: https://shopify.dev/docs/api/functions/latest/product-discount Example of the JSON output structure for a discount applied in Rust, showing the discount strategy, targets, and value. ```json { "discountApplicationStrategy": "FIRST", "discounts": [ { "message": "15% off items with SKU DISC-SKU1", "targets": [ { "cartLine": { "id": "gid://shopify/CartLine/1", "quantity": 2 } } ], "value": { "percentage": { "value": "15.0" } } } ] } ``` -------------------------------- ### Input Object for cart.payment-methods.transform.run (Rust) Source: https://shopify.dev/docs/api/functions/latest/payment-customization Example Rust input object representing payment methods and their configuration for the transformation. ```json { "paymentMethods": [ { "id": "gid://shopify/PaymentCustomizationPaymentMethod/1", "name": "Money Order" }, { "id": "gid://shopify/PaymentCustomizationPaymentMethod/2", "name": "Shopify Payments" }, { "id": "gid://shopify/PaymentCustomizationPaymentMethod/3", "name": "Cash on Delivery (COD)" } ], "paymentCustomization": { "metafield": { "jsonValue": { "payment_methods": [ "Money Order", "Shopify Payments", "Cash on Delivery (COD)" ] } } } } ```