Actions13
Additional → Create a Discount
AI-generatedOverview
This node operation creates a new discount code in a Shopify store using the Streamline API. It is useful for automating the creation of promotional discounts such as seasonal sales or special offers. For example, a user can create a "Summer Sale" discount code that gives customers a 20% discount on all items or a specific product, with options to set the discount's active period, usage limits, and whether it applies once per customer.
Use Case Examples
- Create a discount code 'SAVE20' for 20% off all items valid from January 1, 2025, to January 31, 2025.
- Create a discount code 'SUMMER10' for 10% off a single product with a usage limit of 100 times.
Properties
| Name | Meaning |
|---|---|
| Title | The title of the discount (e.g., 'Summer Sale'). This is a required string input. |
| Code | The discount code string that customers will use (e.g., 'SAVE20'). This is a required string input. |
| Customer Gets - Percentage(0 ~ 1) | The numeric discount value as a percentage (e.g., 0.2 for 20%). This is a required number input. |
| Customer Gets - Items | Specifies whether the discount applies to all items or a single product. Options are 'All' or 'Single Product'. |
| Customer Gets (Value) | Hidden property representing the discount value object with a percentage field, derived from the numeric percentage input. |
| Customer Gets (Items) | Hidden property representing the items the discount applies to, either all items or a specific product identified by its Shopify product ID. |
| Starts At | ISO date string indicating when the discount becomes active. This is a required string input. |
| Ends At | Optional ISO date string indicating when the discount ends. |
| Usage Limit | Optional maximum number of times the discount code can be used. |
| Applies Once Per Customer | Boolean flag indicating if the discount applies only once per customer. |
Output
JSON
id- Unique identifier of the created discount code.title- Title of the discount.code- Discount code string.customerGetsvalue
*percentage- Discount percentage value.items
*all- Boolean indicating if discount applies to all items.
*products
*productsToAdd- Array of product IDs the discount applies to if not all items.
startsAt- ISO date when the discount becomes active.endsAt- ISO date when the discount ends.usageLimit- Maximum usage limit of the discount code.appliesOncePerCustomer- Flag indicating if discount applies once per customer.
Dependencies
- Streamline API with an API key credential
Troubleshooting
- Ensure all required fields (Title, Code, Customer Gets Percentage, Starts At) are provided to avoid validation errors.
- Verify the format of ISO date strings for Starts At and Ends At to prevent date parsing errors.
- If applying discount to a single product, ensure the product ID is correctly formatted as a Shopify GID (e.g., gid://shopify/Product/123456789012345).
- Check API credentials and network connectivity if the request to create the discount fails.
Links
- Shopify Discount Code API - Official Shopify API documentation for managing discount codes.