Skip to main content

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*, 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.

body.bonusAmount: number
Bonus amount to apply.

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(body);

Example response

{
"totalSum": 300,
"totalSumWithDiscount": 285,
"bonusApplied": 0,
"totalDue": 285,
"discountConfig": {
"orderDiscounts": [
{
"id": 2,
"identifier": "personal_discount",
"type": "PERSONAL_DISCOUNT",
"localizeInfos": {
"title": "Personal discount"
},
"startDate": "2026-04-21T18:26:19.815Z",
"endDate": "2028-03-21T19:26:24.741Z",
"discountValue": {
"value": 15,
"maxAmount": null,
"discountType": "FIXED_AMOUNT",
"applicability": "TO_ORDER"
},
"exclusions": null,
"position": 1,
"conditionLogic": "AND",
"gifts": [],
"userGroups": null,
"userExclusions": null,
"conditions": [],
"coupon": null
}
],
"productDiscounts": [],
"coupon": null,
"settings": {
"allowStacking": true,
"maxDiscountValue": 50,
"allowGiftStacking": false,
"maxBonusPaymentPercent": null,
"minBonusAmount": null,
"minOrderAmountForBonus": null,
"giftRefundPolicy": "KEEP_GIFT"
},
"bonus": {
"availableBalance": 0,
"maxBonusDiscount": 0,
"minBonusAmount": null,
"minOrderAmountForBonus": null,
"bonusApplied": 0
}
},
"currency": "USD",
"orderPreview": [
{
"id": 2957,
"isGift": false,
"price": 150,
"discountPrice": null,
"quantity": 2
}
]
}

Response schema

Schema: IOrderPreviewResponse

totalSum: number
Total order amount before discounts.
example: 300

totalSumWithDiscount: number
Total order amount after discounts.
example: 250

discountConfig: IOrderDiscountConfig
Discount configuration applied to the order.

discountConfig.bonus: IOrderDiscountBonus | null
Bonus calculation result, null when bonuses are not used, or omitted entirely when the order has no bonus context.

discountConfig.coupon: unknown | null
Resolved coupon, or null when no coupon is applied.

discountConfig.orderDiscounts: unknown[]
Order-level discounts that were matched and applied.

discountConfig.productDiscounts: unknown[]
Product-level discounts that were matched and applied.

discountConfig.settings: IOrderDiscountSettings
Stacking and cap settings used during calculation.

discountConfig.additionalDiscountsMarkers: string[]
Markers of extra discounts requested by the client (omitted in preview responses).

discountConfig.bonusApplied: number
Bonus amount applied to the order (omitted in preview responses).
example: 0

discountConfig.excludedGiftProductIds: string[]
Product ids excluded from gift selection (omitted in preview responses).

discountConfig.totalDue: number
Total amount due after discounts and bonuses (omitted in preview responses).
example: 300

discountConfig.totalRaw: number
Total amount before discounts (omitted in preview responses).
example: 300

discountConfig.totalSumWithDiscount: number
Total amount after discounts but before bonuses (omitted in preview responses).
example: 300

currency: string
Currency of the order.
example: "USD"

orderPreview: IOrderPreviewItem[]
Array of order preview items.

orderPreview.id: number
Product identifier.
example: 2954

orderPreview.price: number
Product unit price before discounts.
example: 51

orderPreview.quantity: number
Quantity of the product.
example: 1

orderPreview.discountPrice: number | null
Unit price after discounts, or null when no discount applies.
example: null

orderPreview.isGift: boolean
Whether the product is delivered as a gift.
example: false

bonusApplied: number
Bonus applied to the order.

totalDue: number
Total due after bonuses.