Calculate cart details

Ecwid.Cart.calculateTotal()

This method calculates the current cart asynchronously and passes the result as an order callback argument with a snapshot of the generated order with essential details.

Example of the call and response
Ecwid.Cart.calculateTotal(function(order) {
  console.log(JSON.stringify(order));
});

/* prints

{
    "subtotal": 3500,
    "subtotalWithoutTax": 3500,
    "total": 3850,
    "totalWithoutTax": 3500,
    "tax": 350,
    "couponDiscount": 0,
    "volumeDiscount": 0,
    "customerGroupDiscount": 0,
    "customerGroupVolumeDiscount": 0,
    "discount": 0,
    "shipping": 0,
    "shippingWithoutTax": 0,
    "handlingFee": 0,
    "handlingFeeWithoutTax": 0,
    "pricesIncludeTax": false,
    "cart": {
        "id": "TJ6VG",
        "cartId": "99E7E224-5F6F-4C00-BFE9-9F72F2B5A471",
        "orderId": 506524300,
        "items": [
            {
                "quantity": 3,
                "product": {
                    "id": 455570501,
                    "sku": "0000077",
                    "price": 500,
                    "name": "Pizza #2",
                    "weight": 1,
                    "shortDescription": "",
                    "url": "https://example.company.site/products/Example-product-p455570501"
                },
                "options": {}
            },
            {
                "quantity": 4,
                "product": {
                    "id": 439710255,
                    "sku": "000001",
                    "price": 500,
                    "name": "Pizza",
                    "weight": 1,
                    "shortDescription": "123 pie",
                    "url": "https://wexample.company.site/products/Example-product-2-p439710255"
                },
                "options": {
                    "Size": "L, R",
                    "djbfdmnfb": "1234"
                }
            }
        ],
        "productsQuantity": 7,
        "shippingMethod": "Pickup",
        "shippingPerson": {
            "countryCode": "GE",
            "countryName": "Georgia",
            "name": "Jon Stewart Doe",
            "phone": "16019521325",
            "stateOrProvinceCode": "TB"
        },
        "weight": 7
    }
}

*/

order argument fields

Name
Type
Description

cart

object cart

Contains full cart details after calculation matching the Ecwid.Cart.get() result.

couponDiscount

number

Total discount from applied coupons.

customerGroupDiscount

number

Discount value from customer group discounts.

customerGroupVolumeDiscount

number

Absolute discount from customer group discounts.

discount

number

Total discount value from all sources.

handlingFee

number

Total fees applied to order.

handlingFeeWithoutTax

number

Total fees applied to order before taxes.

pricesIncludeTax

boolean

Specifies if product prices include taxes defining tax calculation formulae. If true, the store works with "gross prices". If false the store works with "net prices".

shipping

number

Total shipping cost.

shippingWithoutTax

number

Total shipping cost before taxes applied.

subtotal

number

Order subtotal. Includes the shopping cart total with discounts and taxes but without shipping costs or handling fees.

subtotalWithoutTax

number

Order subtotal before applied taxes.

tax

number

Total sum of taxes applied to order.

total

number

Order total that includes all costs, fees, taxes, and discounts.

totalWithoutTax

number

Order total before taxes applied.

volumeDiscount

number

Total discount for order subtotal.

Last updated

Was this helpful?