LogoLogo
Build appsContact API support
Storefronts
  • Build apps
  • Site Templates
  • API Reference
  • Changelog
Storefronts
  • Ecwid storefronts overview
  • Get started
    • Storefront customization options
    • Quickstart: customize storefront with Ecwid JS API
  • Track Storefront events
    • "Page is loaded" events
    • "Customer logged in" event
    • "Cart details are changed" event
    • "New order is placed" event
    • "Instant Site section load" events
  • Get Storefront details
    • Get Ecwid store ID
    • Get storefront language and currency
    • Get visitor location
    • Get public app details
  • Manage customers on the storefront
    • Get logged in customer's details
    • Manage customer's cookie consent
    • Log out customer
  • Open page on the storefront
    • Overview of open page options
    • Open product pages with params
    • Open category pages with params
    • Open search page with params
    • Open account pages with params
  • Manage cart and checkout
    • Get cart details
    • Add product to the cart
    • Remove product from the cart
    • Fully clear the cart
    • Create pre-filled shopping carts
    • Calculate cart details
    • Send customer to the checkout
    • Set customer's email for the checkout
    • Set customer's comments for order
    • Set customer's shipping and billing addresses
    • Set custom order referer
  • Store configuration settings
    • Overview
    • Behavioral configs
    • Design configs

Lightspeed® 2025

On this page

Was this helpful?

  1. Manage cart and checkout

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 2 months ago

Was this helpful?