Overview
This node manages price rules and discounts on the Sapo e-commerce platform. It allows users to create, retrieve, update, delete, count, and list price rules that define promotional pricing or discounts for products or orders.
Common scenarios include:
- Creating a new discount campaign (e.g., a summer sale with percentage off).
- Retrieving details of an existing price rule.
- Updating an existing price rule’s parameters.
- Deleting obsolete or expired price rules.
- Counting total price rules for reporting.
- Listing multiple price rules with filtering options.
Practical example: A store owner wants to create a 20% off discount valid from June to August for all customers on all line items. This node can create that price rule by providing the appropriate JSON data.
Properties
| Name | Meaning |
|---|---|
| Thao Tác (operation) | The action to perform: Count, Create, Delete, Get details, List many, or Update price rules. |
| ID Quy Tắc Giá | Numeric ID of the price rule (required for get, update, delete operations). |
| Trả Về Tất Cả | Boolean to return all results when listing price rules, or limit the number returned. |
| Giới Hạn | Maximum number of price rules to return when not returning all (minimum 1). |
| Thông Tin Bổ Sung | Additional filters for listing price rules, such as status (active, disabled, expired), title, or creation date range. |
| Dữ Liệu Quy Tắc Giá | JSON object defining the price rule data, required for create and update operations. Example fields include title, value_type, value, start/end dates, customer selection, target type, and target selection. |
Output
The node outputs an array with one item containing a json field:
- For create, get, update, list, and count operations, the
jsoncontains the response data from the Sapo API representing the price rule(s) or count. - For delete, the output is
{ "success": true }if deletion was successful. - In case of errors (if not continuing on fail), the node throws an error; otherwise, it outputs
{ "error": "<error message>" }.
No binary data is output by this node.
Dependencies
- Requires an active connection to the Sapo API via an API key credential configured in n8n.
- Uses the internal Sapo API base class to interact with price rules endpoints.
- Network access to Sapo's API endpoints is necessary.
Troubleshooting
Common issues:
- Invalid or missing API credentials will cause authentication failures.
- Providing malformed JSON in the "Dữ Liệu Quy Tắc Giá" property may result in API errors.
- Using an invalid or non-existent price rule ID for get, update, or delete operations will cause not found errors.
- Exceeding API rate limits or network connectivity problems can cause request failures.
Error messages:
- Errors from the Sapo API are surfaced with their message and stack trace.
- If "Continue On Fail" is enabled, errors are returned in the output JSON under the
errorkey instead of stopping execution.
To resolve errors:
- Verify API credentials and permissions.
- Ensure JSON input is correctly formatted.
- Confirm the price rule ID exists before updating or deleting.
- Check network connectivity and API status.
Links and References
- Sapo API Documentation (general reference for Sapo API endpoints)
- n8n documentation on creating custom nodes