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 applied to products or orders.
Common scenarios where this node is useful include:
- Automating promotional campaigns by creating or updating discount rules.
- Fetching details of specific price rules for reporting or validation.
- Removing outdated or invalid price rules.
- Counting total price rules for inventory or audit purposes.
- Listing multiple price rules with filtering options.
For example, a user can schedule a summer sale discount by creating a price rule with a percentage off valid during certain dates, or update an existing rule to change its discount value.
Properties
| Name | Meaning |
|---|---|
| Thao Tác (operation) | The action to perform on price rules. Options: Đếm (count), Tạo Mới (create), Xóa (delete), Lấy Chi Tiết (get), Lấy Danh Sách (getMany), Cập Nhật (update). |
| ID Quy Tắc Giá (priceRuleId) | Numeric identifier of the price rule. Required for get, update, and delete operations. |
| Trả Về Tất Cả (returnAll) | Boolean indicating whether to return all results when listing price rules (getMany). If false, limits results to a specified number. |
| Giới Hạn (limit) | Maximum number of price rules to return when returnAll is false in getMany operation. Minimum 1. |
| Thông Tin Bổ Sung (additionalFields) | Additional filters for listing price rules, such as status (active, disabled, expired), title, creation date range (created_at_min, created_at_max). Only applies to getMany operation. |
| Dữ Liệu Quy Tắc Giá (data) | JSON object containing the price rule data for create and update operations. Example fields include title, value_type (e.g., percentage), value (discount amount), start and end dates, customer selection, target type. |
Output
The node outputs an array with one item containing a json field representing the result of the operation:
- For create, get, update: The JSON contains the full details of the affected price rule.
- For getMany: The JSON contains a list of price rules matching the criteria.
- For delete: The JSON contains
{ success: true }if deletion was successful. - For count: The JSON contains
{ count: <number> }representing the total number of price rules.
No binary data output is produced by this node.
Dependencies
- Requires connection to the Sapo API via an API key credential configured in n8n.
- Uses an internal helper class to interact with Sapo's price rules endpoints.
- No additional external dependencies beyond the Sapo API and n8n environment.
Troubleshooting
Common issues:
- Invalid or missing API credentials will cause authentication failures.
- Providing an invalid or non-existent priceRuleId for get, update, or delete operations will result in errors.
- Malformed JSON in the "Dữ Liệu Quy Tắc Giá" property may cause parsing or API errors.
- Exceeding API rate limits could cause temporary failures.
Error messages:
- Errors from the Sapo API are caught and returned as node errors unless "Continue On Fail" is enabled.
- Typical error messages include "Not Found" for invalid IDs, "Unauthorized" for credential issues, or validation errors for incorrect data formats.
Resolutions:
- Verify API credentials and permissions.
- Double-check the priceRuleId values.
- Validate JSON input before running the node.
- Use "Continue On Fail" cautiously to handle partial failures gracefully.
Links and References
- Sapo API Documentation
- n8n Documentation on Creating Custom Nodes
- JSON Schema Validator Tools (useful for validating the JSON input property)