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

# Load Cart

> Learn to load a guest cart session securely

<Info>
  This feature is not part of the REST API. Do not treat it as such!
</Info>

This feature is designed to transfer the cart over to the web version of your store.

It allows the guest customer to continue shopping or checkout what they already have in the cart added via your headless application.

It's handy if you have not yet worked with payment gateway like *Stripe* to handle the headless checkout.

You can choose to override the cart (if anything is set) or merge the cart items together.

<Note>
  If a customer is logged in via the web version of your store then **WooCommerce** will then merge any items in the cart together with the items the guest customer has in cart.
</Note>

<Info>
  FYI: It does not matter if your customer is logged in or not already via the web version of your store. Only the cart data will be set. Customer details are **not transferred**.
</Info>

## Query properties

| Query              | Type   | Description                                                                                       |
| ------------------ | ------ | ------------------------------------------------------------------------------------------------- |
| `cocart-load-cart` | string | Set the cart key of the cart you wish to load. **mandatory**                                      |
| `notify`           | bool   | Set as true to notify customers once arrived on the web version of your store. *Default is false* |
| `keep-cart`        | bool   | Set as false to merge cart data. *Default is true*                                                |

To load the cart from session on your web store, you must use the properties above to query your website. You can query any page you prefer your customer to land on as the cart is loaded in the background.

`https://example-store.com/checkout/?cocart-load-cart=bbfa8e97ac9cff4c861d62a109e83bb6`

<Info>
  If the same item already exists in cart and you are merging the two carts together, that item will not change. It will not increase or decrease the quantity if the cart item key are the same.
</Info>

### FAQ

<AccordionGroup>
  <Accordion title="What happens if the cart does not load?">
    Use the notice property to try loading the cart session again. This can be used also to debug why but normally this is because of two things.

    1. The cart key was incorrect
    2. The cart session has expired and is no longer in the database under that cart key.
  </Accordion>

  <Accordion title="I want to change the query name">
    Use this filter to change the name.

    ```php theme={"system"}
    <?php
    add_filter( 'cocart_load_cart_query_name', function() {
        return 'redpill'; // All im offering is the truth nothing more.
    });
    ```
  </Accordion>

  <Accordion title="I want this feature disabled. Do not need it.">
    If you do not need or want to use WooCommerce native checkout then disable using this filter.

    ```php theme={"system"}
    <?php
    add_filter( 'cocart_disable_load_cart', function() {
        return true;
    });
    ```
  </Accordion>
</AccordionGroup>
