> ## 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.

# Get cart

> Get the full cart including all items, totals, and customer information.



## OpenAPI

````yaml api-reference/v2/openapi-v2-stable.yaml get /cart
openapi: 3.0.3
info:
  title: CoCart - Cart API v2
  version: 4.6.0
  description: >
    CoCart REST API v2 for managing shopping carts, products, and store
    functionality.

    Compared to API v1, this version provides enhanced endpoints for cart
    operations, product management,

    and administrative functions with improved response structures and better
    error handling.
  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/v2'
    description: API v2
    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: cart-items
    description: Operations for managing cart items
  - name: cart-calculate
    description: Operations for calculating cart totals
  - name: products
    description: Operations for browsing and retrieving product information
  - name: product-attributes
    description: Operations for retrieving product attributes and attribute terms
  - name: product-categories
    description: Operations for browsing and filtering product categories
  - name: product-tags
    description: Operations for browsing and filtering product tags
  - name: product-reviews
    description: Operations for retrieving product reviews and ratings
  - name: product-variations
    description: Operations for retrieving variable product variations
  - name: admin-sessions
    description: Administrative operations for managing cart sessions
  - name: authentication
    description: Operations for user authentication
  - name: store
    description: Operations for retrieving store information and configuration
externalDocs:
  description: Find out more about CoCart API
  url: https://docs.cocartapi.com
paths:
  /cart:
    get:
      tags:
        - cart
      summary: Get cart contents
      description: >
        Gets the cart contents including items, totals, and customer
        information.
      parameters:
        - name: cart_key
          in: query
          description: Unique identifier for the cart/customer.
          schema:
            type: string
          required: false
        - name: fields
          in: query
          description: >-
            Specify each parent field you want to request separated by (,) in
            the response before the data is fetched.
          schema:
            type: string
          required: false
        - name: default
          in: query
          description: Return the default cart data if set to true.
          schema:
            type: boolean
            default: false
          required: false
        - name: thumb
          in: query
          description: >-
            True if you want to return the URL of the featured product image for
            each item in the cart.
          schema:
            type: boolean
            default: true
          required: false
      responses:
        '200':
          description: Cart retrieved successfully.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/CartV2'
              example:
                cart_hash: e629fa6598d732768f7c726b4b621285
                cart_key: cb7a23af96a3f23af3c28a8b4b8c6d5e
                currency:
                  currency_code: USD
                  currency_symbol: $
                  currency_symbol_pos: left
                  currency_minor_unit: 2
                  currency_decimal_separator: .
                  currency_thousand_separator: ','
                  currency_prefix: $
                  currency_suffix: ''
                customer:
                  billing_address:
                    billing_first_name: John
                    billing_last_name: Doe
                    billing_company: Acme Corporation
                    billing_country: US
                    billing_address_1: 123 Main Street
                    billing_address_2: Suite 100
                    billing_postcode: '90210'
                    billing_city: Beverly Hills
                    billing_state: CA
                    billing_phone: +1-555-123-4567
                    billing_email: john.doe@example.com
                  shipping_address:
                    shipping_first_name: John
                    shipping_last_name: Doe
                    shipping_company: Acme Corporation
                    shipping_country: US
                    shipping_address_1: 123 Main Street
                    shipping_address_2: Suite 100
                    shipping_postcode: '90210'
                    shipping_city: Beverly Hills
                    shipping_state: CA
                items:
                  d6b3e8e5a1b0c6e4f2a3b1d8c5e6f9a2:
                    item_key: d6b3e8e5a1b0c6e4f2a3b1d8c5e6f9a2
                    id: 145
                    name: Wireless Bluetooth Headphones
                    title: Wireless Bluetooth Headphones
                    price: $18.00
                    quantity:
                      value: 2
                      min_purchase: 1
                      max_purchase: -1
                    totals:
                      subtotal: 36
                      subtotal_tax: 3.6
                      total: 36
                      tax: 3.6
                    slug: wireless-bluetooth-headphones
                    meta:
                      product_type: simple
                      sku: WBH-001
                      dimensions:
                        length: ''
                        width: ''
                        height: ''
                        unit: cm
                      weight: '0.5'
                      variation: {}
                    backorders: 'no'
                    cart_item_data: {}
                    featured_image: >-
                      https://example-store.com/wp-content/uploads/2024/03/headphones-blue.jpg
                  f3a8b2c6d5e9f1a4b7c0d3e6f9a2b5c8:
                    item_key: f3a8b2c6d5e9f1a4b7c0d3e6f9a2b5c8
                    id: 289
                    name: Premium Cotton T-Shirt - Large, Navy Blue
                    title: Premium Cotton T-Shirt
                    price: $80.00
                    quantity:
                      value: 1
                      min_purchase: 1
                      max_purchase: 100
                    totals:
                      subtotal: 80
                      subtotal_tax: 8
                      total: 80
                      tax: 8
                    slug: premium-cotton-tshirt
                    meta:
                      product_type: variation
                      sku: PCT-LG-NB
                      dimensions:
                        length: '25'
                        width: '20'
                        height: '2'
                        unit: cm
                      weight: '0.2'
                      variation:
                        attribute_pa_size: Large
                        attribute_pa_color: Navy Blue
                    backorders: 'no'
                    cart_item_data: {}
                    featured_image: >-
                      https://example-store.com/wp-content/uploads/2024/03/tshirt-navy.jpg
                item_count: 3
                items_weight: 1.5
                coupons:
                  - coupon: SUMMER20
                    label: Summer Sale 20% Off
                    saving: $23.20
                    saving_html: <strong>$23.20</strong>
                needs_payment: true
                needs_shipping: true
                shipping:
                  total_packages: 1
                  show_package_details: true
                  has_calculated_shipping: true
                  packages:
                    default:
                      package_name: Shipping
                      rates:
                        flat_rate_1:
                          key: flat_rate:1
                          method_id: flat_rate
                          instance_id: 1
                          label: Flat Rate
                          cost: '10.00'
                          html: 'Flat Rate: $10.00'
                          taxes: '1.00'
                          chosen_method: true
                        free_shipping_2:
                          key: free_shipping:2
                          method_id: free_shipping
                          instance_id: 2
                          label: Free Shipping
                          cost: '0.00'
                          html: Free Shipping
                          taxes: '0.00'
                          chosen_method: false
                      package_details: Shipped from Main Warehouse
                      index: 0
                      chosen_method: flat_rate:1
                      formatted_destination: Beverly Hills, CA 90210, US
                fees:
                  - name: Gift Wrapping
                    amount: 5
                    taxable: true
                    tax_class: standard
                    total: 5
                    tax: 0.5
                taxes:
                  - rate_id: 1
                    label: Sales Tax
                    compound: false
                    tax_total: '13.10'
                    shipping_tax_total: '1.00'
                totals:
                  subtotal: '116.00'
                  subtotal_tax: '11.60'
                  shipping_total: '10.00'
                  shipping_tax: '1.00'
                  shipping_taxes:
                    - 1
                  discount_total: '23.20'
                  discount_tax: '0.00'
                  cart_contents_total: '92.80'
                  cart_contents_tax: '11.10'
                  cart_contents_taxes:
                    - 11.1
                  fee_total: '5.00'
                  fee_tax: '0.50'
                  fee_taxes:
                    - 0.5
                  total: '119.40'
                  total_tax: '13.60'
                removed_items: []
                cross_sells:
                  - id: 312
                    product_name: Wireless Charging Pad
                    product_title: Wireless Charging Pad
                    price: $29.99
                    regular_price: $39.99
                    sale_price: $29.99
                    product_image: >-
                      https://example-store.com/wp-content/uploads/2024/03/charging-pad.jpg
                  - id: 445
                    product_name: Phone Case - Universal
                    product_title: Phone Case - Universal
                    price: $15.99
                    regular_price: $15.99
                    sale_price: ''
                    product_image: >-
                      https://example-store.com/wp-content/uploads/2024/03/phone-case.jpg
                extensions: {}
        '400':
          description: Bad request - invalid parameters provided.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: cocart_invalid_parameter
                message: Invalid cart_key parameter.
                data:
                  status: 400
        '404':
          description: Cart not found.
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ErrorResponse'
              example:
                code: cocart_cart_not_found
                message: Cart not found.
                data:
                  status: 404
components:
  schemas:
    CartV2:
      type: object
      description: Complete cart object with enhanced v2 structure.
      properties:
        cart_hash:
          type: string
          description: Unique cart hash.
        cart_key:
          type: string
          description: Unique cart key for the customer.
        currency:
          $ref: '#/components/schemas/Currency'
        customer:
          $ref: '#/components/schemas/Customer'
        items:
          type: object
          description: Cart items indexed by item key.
          additionalProperties:
            $ref: '#/components/schemas/CartItem'
        item_count:
          type: integer
          description: Total number of items in cart.
        items_weight:
          type: number
          description: Total weight of all items.
        coupons:
          type: array
          description: Applied coupons.
          items:
            $ref: '#/components/schemas/AppliedCoupon'
        needs_payment:
          type: boolean
          description: Whether the cart needs payment.
        needs_shipping:
          type: boolean
          description: Whether the cart needs shipping.
        shipping:
          $ref: '#/components/schemas/Shipping'
        fees:
          type: array
          description: Cart fees.
          items:
            $ref: '#/components/schemas/CartFee'
        taxes:
          type: array
          description: Cart taxes.
          items:
            $ref: '#/components/schemas/CartTax'
        totals:
          $ref: '#/components/schemas/CartTotals'
        removed_items:
          type: array
          description: Recently removed items that can be restored.
          items:
            $ref: '#/components/schemas/RemovedItem'
        cross_sells:
          type: array
          description: Cross-sell products.
          items:
            $ref: '#/components/schemas/CrossSellItem'
        notices:
          type: object
          description: Cart notices and messages.
          additionalProperties: true
        extensions:
          type: object
          description: Additional data from extensions.
          additionalProperties: true
    ErrorResponse:
      type: object
      description: Standard error response structure.
      properties:
        code:
          type: string
          description: Machine-readable error code.
          example: cocart_invalid_parameter
        message:
          type: string
          description: Human-readable error message.
          example: Invalid parameter provided.
        data:
          type: object
          description: Additional error data.
          properties:
            status:
              type: integer
              description: HTTP status code.
              example: 400
            params:
              type: object
              description: Parameter-specific error details.
              additionalProperties: true
          additionalProperties: true
    Currency:
      type: object
      properties:
        currency_code:
          type: string
          description: Currency code.
        currency_symbol:
          type: string
          description: Currency symbol.
        currency_symbol_pos:
          type: string
          description: Currency symbol position.
        currency_minor_unit:
          type: integer
          description: Currency minor unit.
        currency_decimal_separator:
          type: string
          description: Currency decimal separator.
        currency_thousand_separator:
          type: string
          description: Currency thousand separator.
        currency_prefix:
          type: string
          description: Currency prefix.
        currency_suffix:
          type: string
          description: Currency suffix.
    Customer:
      type: object
      properties:
        billing_address:
          $ref: '#/components/schemas/BillingAddress'
        shipping_address:
          $ref: '#/components/schemas/ShippingAddress'
    CartItem:
      type: object
      properties:
        item_key:
          type: string
          description: Unique identifier for the item within the cart.
        id:
          type: integer
          description: Product ID.
        name:
          type: string
          description: Product name.
        title:
          type: string
          description: Product title.
        price:
          type: string
          description: Current product price.
        quantity:
          type: object
          description: Quantity information for this item.
          properties:
            value:
              type: number
              description: Current quantity of the item in the cart.
            min_purchase:
              type: number
              description: Minimum quantity that can be purchased.
            max_purchase:
              type: number
              description: Maximum quantity that can be purchased.
        totals:
          type: object
          description: Item totals.
          properties:
            subtotal:
              type: number
              description: Line subtotal (before discounts).
            subtotal_tax:
              type: number
              description: Line subtotal tax.
            total:
              type: number
              description: Line total (after discounts).
            tax:
              type: number
              description: Line total tax.
        slug:
          type: string
          description: Product slug.
        meta:
          type: object
          description: Item metadata.
          properties:
            product_type:
              type: string
              description: Product type.
            sku:
              type: string
              description: Product SKU.
            dimensions:
              type: object
              description: Product dimensions.
              properties:
                length:
                  type: string
                  description: Product length.
                width:
                  type: string
                  description: Product width.
                height:
                  type: string
                  description: Product height.
                unit:
                  type: string
                  description: Dimension unit.
            weight:
              type: string
              description: Product weight.
            variation:
              description: Chosen attributes (for variations).
              oneOf:
                - type: object
                  additionalProperties:
                    type: string
                - type: array
                  items:
                    type: string
          additionalProperties: true
        backorders:
          type: string
          description: Backorder status.
        cart_item_data:
          type: object
          description: Custom cart item data.
          additionalProperties: true
        featured_image:
          type: string
          description: Product featured image URL.
    AppliedCoupon:
      type: object
      properties:
        coupon:
          type: string
        label:
          type: string
        saving:
          type: string
        saving_html:
          type: string
    Shipping:
      type: object
      properties:
        total_packages:
          type: integer
          description: Number of shipping packages.
        show_package_details:
          type: boolean
          description: Whether to show package details.
        has_calculated_shipping:
          type: boolean
          description: Whether shipping has been calculated.
        packages:
          type: object
          description: Shipping packages.
          additionalProperties:
            $ref: '#/components/schemas/ShippingPackage'
    CartFee:
      type: object
      properties:
        name:
          type: string
        amount:
          type: number
        taxable:
          type: boolean
        tax_class:
          type: string
        total:
          type: number
        tax:
          type: number
    CartTax:
      type: object
      properties:
        rate_id:
          type: integer
        label:
          type: string
        compound:
          type: boolean
        tax_total:
          type: string
        shipping_tax_total:
          type: string
    CartTotals:
      type: object
      properties:
        subtotal:
          type: string
          description: Cart subtotal.
        subtotal_tax:
          type: string
          description: Cart subtotal tax.
        shipping_total:
          type: string
          description: Shipping total.
        shipping_tax:
          type: string
          description: Shipping tax.
        shipping_taxes:
          type: array
          items:
            type: number
        discount_total:
          type: string
          description: Discount total.
        discount_tax:
          type: string
          description: Discount tax.
        cart_contents_total:
          type: string
          description: Cart contents total.
        cart_contents_tax:
          type: string
          description: Cart contents tax.
        cart_contents_taxes:
          type: array
          items:
            type: number
        fee_total:
          type: string
          description: Fee total.
        fee_tax:
          type: string
          description: Fee tax.
        fee_taxes:
          type: array
          items:
            type: number
        total:
          type: string
          description: Cart total.
        total_tax:
          type: string
          description: Total tax.
    RemovedItem:
      type: object
      properties:
        key:
          type: string
        product_id:
          type: integer
        quantity:
          type: integer
        name:
          type: string
    CrossSellItem:
      type: object
      properties:
        id:
          type: integer
        product_name:
          type: string
        product_title:
          type: string
        price:
          type: string
        regular_price:
          type: string
        sale_price:
          type: string
        product_image:
          type: string
    BillingAddress:
      type: object
      properties:
        billing_first_name:
          type: string
        billing_last_name:
          type: string
        billing_company:
          type: string
        billing_country:
          type: string
        billing_address_1:
          type: string
        billing_address_2:
          type: string
        billing_postcode:
          type: string
        billing_city:
          type: string
        billing_state:
          type: string
        billing_phone:
          type: string
        billing_email:
          type: string
    ShippingAddress:
      type: object
      properties:
        shipping_first_name:
          type: string
        shipping_last_name:
          type: string
        shipping_company:
          type: string
        shipping_country:
          type: string
        shipping_address_1:
          type: string
        shipping_address_2:
          type: string
        shipping_postcode:
          type: string
        shipping_city:
          type: string
        shipping_state:
          type: string
    ShippingPackage:
      type: object
      properties:
        package_name:
          type: string
          description: Package name.
        rates:
          type: object
          description: Available shipping rates.
          additionalProperties:
            $ref: '#/components/schemas/ShippingRate'
        package_details:
          type: string
          description: Package details.
        index:
          type: integer
          description: Package index.
        chosen_method:
          type: string
          description: Chosen shipping method.
        formatted_destination:
          type: string
          description: Formatted destination address.
    ShippingRate:
      type: object
      properties:
        key:
          type: string
        method_id:
          type: string
        instance_id:
          type: integer
        label:
          type: string
        cost:
          type: string
        html:
          type: string
        taxes:
          type: string
        chosen_method:
          type: boolean

````