Skip to main content

previewOrder

Preview an order calculation without creating it. Authorization is optional. Without it, the preview has no bonus data: discountConfig.bonus is null, bonusApplied is 0 and any bonusAmount is ignored. For an authorized user, the preview includes their bonus balance.

Description​

Calculates an order without creating it: product totals, applied discounts and bonuses, and the amount due. Resolves to an IOrderPreviewResponse.

The body takes only products and, optionally, couponCode, additionalDiscountsMarkers and bonusAmount; no form or payment account is needed. products is required and must not be empty; otherwise the API responds with a 400 error.

.previewOrder(

,

);

Parameters schema​

Schema

body(required): ICreateOrderPreview
Order preview parameters.

body.products: IPreviewOrderProduct[]
Products to include in the preview.

products.productId: number
Product ID.
example: 1

products.quantity: number
Quantity of the product.
example: 2

body.couponCode: string
Coupon code to apply.

body.additionalDiscountsMarkers: string[]
Markers of additional discounts to apply.

body.bonusAmount: number
Bonus amount to apply.

langCode: string
Language code. Default: the langCode passed to defineOneEntry ("en_US" if none).
example: "en_US"

Examples​

Minimal example​


const body = {
{
,
}
]
};

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; omitted when the order has no bonus context.

discountConfig.coupon: unknown | null
Applied 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 additional 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[]
Preview of the order items.

orderPreview.id: number
Product ID.
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 a gift.
example: false

bonusApplied: number
Bonus amount applied to the order.

totalDue: number
Total due after bonuses.