previewOrder
Preview an order calculation without creating it. 🔐 This method requires authorization.
Description
This method calculates and previews an order - including product totals, applied discounts, and the final sum - without actually creating the order in the system. It returns a Promise that resolves to an IPreviewOrderEntity object.
Orders.previewOrder(
body*,
body.products,
products.productId,
products.quantity,
body.couponCode,
body.additionalDiscountsMarkers,
langCode
);
Parameters schema
Schema
body(required): ICreateOrderPreview
Order preview body
body.products: IPreviewOrderProduct[]
Array of products to preview.
products.productId: number
Product identifier.
example: 1
products.quantity: number
Quantity of the product.
example: 2
body.couponCode: string
Coupon code to apply.
body.additionalDiscountsMarkers: string[]
Array of additional discount markers.
langCode: string
Language code. Default: "en_US"
example: "en_US"
Examples
Minimal example
const body = { "formIdentifier": "orderForm", "paymentAccountIdentifier": "cash", "formData": { { "marker": "order_name", "type": "string", "value": "Ivan" } }, "products": [ { "productId": 2957, "quantity": 2 } ]};
const response = await Orders.previewOrder("my_order", body);
Example response
{
"formIdentifier": "orderForm",
"paymentAccountIdentifier": "cash",
"formData": [
{
"marker": "order_name",
"value": "Ivan",
"type": "string"
}
],
"products": [
{
"productId": 2957,
"quantity": 2
}
],
"currency": "usd",
"totalSum": 300
}
Response schema
Schema: IOrderPreviewResponse
totalSum: number
Total order amount before discounts.
example: 300
totalSumWithDiscount: number
Total order amount after discounts.
example: 250
discountConfig: unknown
Discount configuration applied to the order.
currency: string
Currency of the order.
example: "USD"
orderPreview: IOrderPreviewItem[]
Array of order preview items.