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 discounts or pricing strategies for products or orders.
Common scenarios include:
- Creating promotional discounts for sales campaigns.
- Retrieving details of a specific price rule to display or modify it.
- Updating existing price rules to adjust discount values or validity periods.
- Deleting obsolete or expired price rules.
- Counting total price rules for reporting or management purposes.
- Listing multiple price rules with optional filters such as status or creation date.
Practical example: A store owner wants to create a summer sale discount of 20% off all items. They can use this node to create a new price rule specifying the discount percentage, start and end dates, and target customers.
Properties
| Name | Meaning |
|---|---|
| Thao Tác | Operation to perform: Count, Create, Delete, Get Detail, Get Many (list), Update |
| ID Quy Tắc Giá | Numeric ID of the price rule; required for Get Detail, Update, and Delete operations |
| Trả Về Tất Cả | Boolean flag to return all results when listing price rules (Get Many operation) |
| Giới Hạn | Maximum number of price rules to return when not returning all (Get Many operation) |
| Thông Tin Bổ Sung | Additional filter fields for listing price rules, including Status (Active, Disabled, Expired), Title, Created After, Created Before |
| Dữ Liệu Quy Tắc Giá | JSON object containing price rule data for Create and Update operations, e.g., title, value type, discount value, start/end dates, customer selection, target type and selection |
Output
The node outputs an array with one item containing a json field. The structure of json depends on the operation:
- Create: Returns the created price rule object with its properties.
- Get (Lấy Chi Tiết): Returns the detailed price rule object identified by the given ID.
- Get Many (Lấy Danh Sách): Returns a list of price rules, optionally filtered and limited.
- Update: Returns the updated price rule object.
- Delete: Returns
{ success: true }upon successful deletion. - Count: Returns
{ count: <number> }indicating the total number of price rules.
No binary data output is produced by this node.
Dependencies
- Requires an API key credential for authenticating with the Sapo platform.
- Depends on the internal
SapoApiBaseclass to interact with Sapo's price rules API endpoints. - No additional environment variables are explicitly required beyond the API credential.
Troubleshooting
Common issues:
- Providing an invalid or missing price rule ID for operations that require it (Get, Update, Delete) will cause errors.
- Incorrectly formatted JSON in the "Dữ Liệu Quy Tắc Giá" property may lead to request failures.
- Exceeding API rate limits or network connectivity problems can cause request errors.
Error messages:
- Errors from the API are caught and either thrown as node errors or returned as error objects if "Continue On Fail" is enabled.
- Typical error messages include invalid ID, unauthorized access due to missing/invalid credentials, or validation errors on input data.
Resolution tips:
- Ensure the price rule ID is correct and exists in the Sapo system.
- Validate JSON input before submitting.
- Verify API credentials and permissions.
- Use "Continue On Fail" cautiously to handle partial failures gracefully.
Links and References
- Sapo API Documentation (general reference for Sapo APIs)
- n8n documentation on Creating Custom Nodes
- JSON formatting tools for validating input data