> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cocartapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Calculate cart totals

> Calculates the cart totals including taxes, shipping, and discounts.



## OpenAPI

````yaml api-reference/v1/openapi-cart-v1.yaml post /calculate
openapi: 3.0.3
info:
  title: CoCart - Cart API v1
  version: 4.6.0
  description: API for managing shopping carts
  termsOfService: http://cocartapi.com/terms-of-conditions-polar/
  contact:
    email: support@cocartapi.com
  license:
    name: GNU General Public License v3.0
    url: http://www.gnu.org/licenses/gpl-3.0.html
servers:
  - url: '{protocol}://{host}/wp-json/cocart/v1'
    description: API v1
    variables:
      protocol:
        enum:
          - http
          - https
        default: https
      host:
        default: example-store.com
        description: Your store domain
security: []
tags:
  - name: cart
    description: Operations for managing the shopping cart
  - name: items
    description: Operations for managing cart items
  - name: coupons
    description: Operations for managing cart coupons
  - name: fees
    description: Operations for managing cart fees
  - name: shipping
    description: Operations for managing shipping methods and rates
  - name: calculate
    description: Operations for calculating cart totals
  - name: products
    description: Operations for managing products
externalDocs:
  description: Find out more about CoCart API
  url: https://docs.cocartapi.com
paths:
  /calculate:
    post:
      tags:
        - calculate
      summary: Calculate cart totals
      description: Calculates the cart totals including taxes, shipping, and discounts.
      requestBody:
        required: false
        content:
          application/json:
            schema:
              type: object
              properties:
                return:
                  description: Returns the cart totals once calculated.
                  type: boolean
                  default: false
      responses:
        '200':
          description: Cart totals calculated successfully.
          content:
            application/json:
              schema:
                oneOf:
                  - type: string
                    description: >-
                      Success message when return parameter is false or not
                      provided.
                    example: Cart totals have been calculated.
                  - $ref: '#/components/schemas/CalculateResponse'
        '400':
          description: Bad request - invalid parameters.
components:
  schemas:
    CalculateResponse:
      type: object
      properties:
        subtotal:
          description: Cart subtotal (before taxes and shipping).
          type: string
        subtotal_tax:
          description: Cart subtotal tax amount.
          type: number
        shipping_total:
          description: Total shipping cost.
          type: string
        shipping_tax:
          description: Shipping tax amount.
          type: number
        shipping_taxes:
          description: Array of shipping taxes.
          type: array
          items:
            type: object
        discount_total:
          description: Total discount amount applied.
          type: number
        discount_tax:
          description: Discount tax amount.
          type: number
        cart_contents_total:
          description: Total cart contents value.
          type: string
        cart_contents_tax:
          description: Cart contents tax amount.
          type: number
        cart_contents_taxes:
          description: Array of cart contents taxes.
          type: array
          items:
            type: object
        fee_total:
          description: Total fees applied.
          type: string
        fee_tax:
          description: Fee tax amount.
          type: number
        fee_taxes:
          description: Array of fee taxes.
          type: array
          items:
            type: object
        total:
          description: Cart total amount.
          type: string
        total_tax:
          description: Total tax amount.
          type: number

````