Calculate order details
When you use Create order API call to place a new order in the store, the order is made exactly as you specify it in JSON. But what to do if you need to calculate taxes, fees, discounts, and shipping costs?
This is what the Calculate order detailscall is for. It accepts a cart JSON object and responds with the order JSON object. The resulting object can be instantly used in the Create order call.
Pass cart details
Upon receiving a new request, Ecwid API checks the following cart details to calculate the order:
Product details:
itemsarray for ID, selected options, quantity, wholesale prices, combination ID, and other details of products. Ecwid API doesn't validate product details. You must send product prices in the request, but they can not match the real products from your store.Shipping details:
shippingPerson/billingPersonobjects for delivery address,shippingOptionobject for shipping costs. Pass the correct shipping method name, ID, and type in theshippingOptionobject to get rate calculation.Tax settings: items’ tax classes, customer’s ID and tax exemption. Store tax settings are automatically added to the request and are used in calculations.
Discounts/surcharges: gift cards, discount coupons, promotions, and custom surcharges. Ecwid API doesn't validate discount/surcharge details. You can send any discounts/surcharges in the request, even if they don't match the ones from your store.
Receive calculated order details
In the response, you get a JSON with calculated order details, including:
Taxes (applied automatically)
Promotions (applied automatically)
Shipping costs (if request had a valid shipping method)
Discount coupons (if request had a valid discount coupon)
Gift card application and balance change (if request had a valid gift card)
Custom surcharges/discounts (only if passed in the request)
After receiving a response, remove the "id" and "internalId" fields, and use the resulting JSON in the Place new order with API Place new order with API request.
Last updated
Was this helpful?
