Đơn Hàng KiotViet icon

Đơn Hàng KiotViet

Quản lý đơn hàng từ KiotViet

Overview

This node manages orders in the KiotViet system, a popular retail and inventory management platform. It supports creating new orders, retrieving orders by ID or code, listing multiple orders with filters, updating existing orders, and canceling orders.

Typical use cases include:

  • Automating order creation from external systems or forms.
  • Synchronizing order data between KiotViet and other platforms.
  • Fetching order details for reporting or processing.
  • Updating order information such as products or discounts.
  • Canceling orders programmatically when needed.

For example, you can create a new order specifying branch, products, and customer info; or retrieve all orders within a date range filtered by status.

Properties

Name Meaning
ID Chi Nhánh Branch ID where the order is created (required for creating an order).
Sản Phẩm Trong ĐơN List of products in the order. Each product includes: ID, quantity, price, discount, and note.
Trường Bổ Sung Additional optional fields for the order: Customer ID, description, total discount.

Details on "Sản Phẩm Trong ĐơN" (Order Products)

  • ID Sản Phẩm: Product identifier (required).
  • Số Lượng: Quantity of the product (required).
  • Giá Bán: Sale price per product unit (required).
  • Giảm Giá: Discount amount applied to the product.
  • Ghi Chú: Notes related to the product.

Additional Fields

  • ID Khách Hàng: Customer identifier.
  • Mô Tả: Description of the order.
  • Giảm Giá: Total discount amount for the entire order.

Output

The node outputs JSON data representing the result of the performed operation:

  • For create: Returns the newly created order object including its details.
  • For get and getByCode: Returns the order object matching the specified ID or code.
  • For getAll: Returns a list of orders with pagination info (data array, total count, page size).
  • For update: Returns the updated order object.
  • For cancel: Returns confirmation or details about the canceled order.

If errors occur during execution, the output will contain error messages corresponding to each failed item if "Continue On Fail" is enabled.

The node does not output binary data.

Dependencies

  • Requires an API key credential for authenticating with the KiotViet API.
  • The node uses a shared KiotViet API helper class internally to perform HTTP requests.
  • Proper configuration of the API credential in n8n is necessary before using this node.

Troubleshooting

  • Common issues:

    • Invalid or missing API credentials will cause authentication failures.
    • Providing non-integer values for IDs (branchId, productId, customerId) may cause errors since the code parses them as integers.
    • Missing required parameters like branchId or productId will result in validation errors.
    • Attempting unsupported operations (e.g., update or cancel if not supported by the API) will throw explicit errors.
  • Error messages:

    • "Update operation is not supported by the KiotViet API" or "Cancel operation is not supported by the KiotViet API" indicate that the API endpoint does not support these actions.
    • Network or API errors will be returned as error messages in the output if "Continue On Fail" is enabled.
  • Resolution tips:

    • Ensure all required fields are provided and correctly typed.
    • Verify API credentials and network connectivity.
    • Check the KiotViet API documentation for supported operations and required parameters.

Links and References

Discussion