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

# Global Session Objects

> Access checkout session data through global objects available in the browser

During checkout, Ollie Shop exposes session data through global objects in the browser. These objects contain all the information about the current checkout state—cart items, user data, shipping options, payment methods, and more.

## Available Session Objects

| Object                            | Description                                                                      |
| --------------------------------- | -------------------------------------------------------------------------------- |
| `window.__CHECKOUT_SESSION__`     | Ollie Shop's normalized session with a consistent structure across all platforms |
| `window.__RAW_CHECKOUT_SESSION__` | The raw session data from your e-commerce platform (VTEX, Shopify, etc.)         |

<Info>
  Use `__CHECKOUT_SESSION__` for a consistent data structure regardless of your e-commerce platform. Use `__RAW_CHECKOUT_SESSION__` when you need platform-specific fields not available in the normalized version.
</Info>

## Ollie Shop Session Structure

The `__CHECKOUT_SESSION__` object provides a clean, normalized structure:

<Accordion title="Full Session Example">
  ```json theme={"system"}
  {
    "id": "4d300fb5d13246a1873ef69a650c9a78",
    "cartItems": [
      {
        "id": "14",
        "name": "Soccer Shirt S",
        "variant": "S",
        "brand": "Ollie",
        "category": "Apparel",
        "quantity": 1,
        "price": 5000,
        "originalPrice": 5000,
        "available": true,
        "index": 0,
        "image": "https://example.com/image.png",
        "url": "/soccer-shirt/p"
      }
    ],
    "customerPreferences": {
      "saveData": false,
      "locale": "en-US"
    },
    "shipping": {
      "addresses": [],
      "packages": [],
      "availableQuotes": [],
      "availableCountries": ["USA", "BRA", "NLD"]
    },
    "payment": {
      "availableMethods": [
        {
          "id": "1",
          "type": "credit_card",
          "name": "American Express",
          "installments": [
            { "number": 1, "amount": 5000, "total": 5000, "interestRate": 0 }
          ]
        }
      ],
      "selectedPayments": [],
      "giftCards": [],
      "total": 0,
      "savedCards": []
    },
    "locale": {
      "currency": "USD",
      "country": "USA",
      "language": "en-US"
    },
    "taxes": [],
    "totals": {
      "items": 5000,
      "total": 5000
    },
    "user": {
      "role": "user",
      "isGuest": true
    },
    "readOnly": false
  }
  ```
</Accordion>

### Key Properties

| Property    | Type   | Description                                        |
| ----------- | ------ | -------------------------------------------------- |
| `id`        | string | Unique session identifier                          |
| `cartItems` | array  | Products in the cart with normalized properties    |
| `user`      | object | User information including `isGuest` status        |
| `locale`    | object | Currency, country, and language settings           |
| `totals`    | object | Order totals (items, shipping, discounts, total)   |
| `shipping`  | object | Shipping addresses, packages, and available quotes |
| `payment`   | object | Available payment methods and selected payments    |

## Raw Platform Session (VTEX Example)

The `__RAW_CHECKOUT_SESSION__` object contains the unmodified data from your e-commerce platform. This example shows the VTEX orderForm structure:

<Accordion title="Full VTEX Session Example">
  ```json theme={"system"}
  {
    "orderFormId": "4d300fb5d13246a1873ef69a650c9a78",
    "salesChannel": "1",
    "loggedIn": false,
    "isCheckedIn": false,
    "storeId": null,
    "allowManualPrice": false,
    "canEditData": true,
    "userProfileId": null,
    "userType": null,
    "value": 5000,
    "messages": [],
    "items": [
      {
        "uniqueId": "A1CAC2C73CCE4C7C985F60DAF99C1599",
        "id": "14",
        "productId": "4",
        "refId": "OLL-SOCCER-S",
        "name": "Soccer Shirt S",
        "skuName": "S",
        "price": 5000,
        "listPrice": 5000,
        "sellingPrice": 5000,
        "quantity": 1,
        "seller": "1",
        "imageUrl": "https://example.com/image.png",
        "detailUrl": "/soccer-shirt/p",
        "availability": "available",
        "additionalInfo": {
          "brandName": "Ollie",
          "brandId": "2000001"
        },
        "productCategories": {
          "2": "Apparel"
        }
      }
    ],
    "totalizers": [
      { "id": "Items", "name": "Items Total", "value": 5000 }
    ],
    "shippingData": {
      "address": null,
      "logisticsInfo": [
        {
          "itemIndex": 0,
          "selectedSla": null,
          "shipsTo": ["USA", "BRA", "NLD"]
        }
      ],
      "selectedAddresses": []
    },
    "clientProfileData": null,
    "paymentData": {
      "paymentSystems": [
        {
          "id": 1,
          "name": "American Express",
          "groupName": "creditCardPaymentGroup"
        }
      ],
      "payments": [],
      "giftCards": []
    },
    "sellers": [
      { "id": "1", "name": "VTEX - EUA", "logo": "" }
    ],
    "storePreferencesData": {
      "countryCode": "USA",
      "currencyCode": "USD",
      "currencySymbol": "$"
    }
  }
  ```
</Accordion>

<Info>
  For a complete reference of all VTEX orderForm fields, see the [VTEX orderForm Fields documentation](https://developers.vtex.com/docs/guides/orderform-fields).
</Info>

<Warning>
  The `__RAW_CHECKOUT_SESSION__` structure varies by platform. The properties shown above are specific to VTEX. Shopify and other platforms will have different structures.
</Warning>

## Accessing Session Data

### In Custom Components

Use the [`useCheckoutSession`](/ollie-shop/api/useCheckoutSession) hook to access session data reactively in your components:

```typescript theme={"system"}
import { useCheckoutSession } from "@ollie-shop/sdk";

export default function MyComponent() {
  const { session } = useCheckoutSession();

  return <p>Total: {session.totals.total}</p>;
}
```

### In GTM Custom HTML Tags

Access the global objects directly in [GTM Custom HTML tags](/ollie-shop/analytics/gtm-enrichment):

```html theme={"system"}
<script>
  var session = window.__CHECKOUT_SESSION__ || {};
  var rawSession = window.__RAW_CHECKOUT_SESSION__ || {};

  console.log('Is guest:', session.user?.isGuest);
  console.log('VTEX logged in:', rawSession.loggedIn);
</script>
```

## Related

* [useCheckoutSession Hook](/ollie-shop/api/useCheckoutSession) — React hook for accessing session data
* [Enriching Events with GTM](/ollie-shop/analytics/gtm-enrichment) — Use session data in GTM tags
