## Extension targets The Discounts Allocator API exposes the following [targets](/docs/apps/build/app-extensions/configure-app-extensions#targets): | Target | Output type | Description | | ------ | ----------- | ----------- | | `purchase.discounts-allocator.run` | [FunctionRunResult](#functionrunresult) | Outputs a list of discounts allocations that should be applied to the cart | ## Input The `RunInput` object is the complete schema that your function can receive as [input](/docs/apps/build/functions/input-output#input). For a list of fields that the Shipping Discount API's `Input` object accepts, refer to [Input](/docs/api/functions/reference/discounts-allocator/graphql/input). ### Input Example The following example shows an input query: ```graphql query Input { discounts { id title code discountApplicationStrategy discountProposals { handle message valueType value targets { cartLineId quantity } } metafield(namespace: "testing-app-allocator", key: "single-discount-cap") { value } } presentmentCurrencyRate cart { lines { id quantity cost { amountPerQuantity { amount currencyCode } } merchandise { __typename ... on ProductVariant { id title product { id title } } } } } shop { metafield(namespace: "testing-app-allocator", key: "per-cart-cap") { value } } } ``` The following example shows the resulting input to the query: ```json { "discounts": [ { "id": "gid:\/\/shopify\/DiscountNode\/13", "title": "CAPS", "code": "CAPS", "type": "CodePriceRule", "discountApplicationStrategy": "FIRST", "discountProposals": [ { "handle": "8d783e44-14b9-4c2c-b431-2be340f1f4e1", "message": "CAPS", "valueType": "FIXED_AMOUNT", "value": "10.0", "targets": [ { "cartLineId": "gid:\/\/shopify\/CartLine\/0", "quantity": 5 } ] } ] } ], "presentmentCurrencyRate": "1.2706752", "cart": { "lines": [ { "id": "gid:\/\/shopify\/CartLine\/0", "quantity": 5, "cost": { "amountPerQuantity": { "amount": "32.0", "currencyCode": "CAD" } }, "merchandise": { "__typename": "ProductVariant", "id": "gid:\/\/shopify\/ProductVariant\/17", "title": "Shorts", "product": { "id": "gid:\/\/shopify\/Product\/9", "title": "Shorts" } } }, { "id": "gid:\/\/shopify\/CartLine\/1", "quantity": 6, "cost": { "amountPerQuantity": { "amount": "20.0", "currencyCode": "CAD" } }, "merchandise": { "__typename": "ProductVariant", "id": "gid:\/\/shopify\/ProductVariant\/17", "title": "Shorts", "product": { "id": "gid:\/\/shopify\/Product\/9", "title": "Shorts" } } } ] }, "shop": { "metafield": null } } ``` ## FunctionRunResult The [`FunctionRunResult`][FunctionRunResult] object is the expected [output](/docs/apps/build/functions/input-output#output) for the `purchase.discounts-allocator.run` target. [FunctionRunResult]: /docs/api/functions/reference/discounts-allocator/graphql/functionrunresult ### Result Example The following function result includes two line discounts: ```json { "lineDiscounts": [ { "cartLineId": "gid://shopify/CartLine/0", "quantity": 5, "allocations": [ { "discountProposalId": "8d783e44-14b9-4c2c-b431-2be340f1f4e1", "amount": 10.0 } ] }, { "cartLineId": "gid://shopify/CartLine/1", "quantity": 6, "allocations": [ { "discountProposalId": "a7194cec-d807-4c46-9284-4fec7a3f5fbe", "amount": 24.0 } ] } ], "displayableErrors": [] } ```