> For the complete documentation index, see [llms.txt](https://docs.umbcheckout.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.umbcheckout.net/v17/core-services/basket-service.md).

# Basket Service

A service which handles all things around the basket

The basket service is what and handles all the UmbCheckout Basket operations.

You can access the basket service by injecting `IBasketService` which can be found within the namespace `UmbCheckout.Core.Interfaces`

{% hint style="info" %}
Every method also has an overload that takes a `CancellationToken` as its last parameter. Call that one: the overloads without a token are `[Obsolete]`. See [Cancellation Tokens](/v17/core-services/cancellation-tokens.md).
{% endhint %}

Adding throws an `ArgumentException` (or `ArgumentOutOfRangeException`) when a line has no currency, when a quantity is outside 1–999,999, when the Basket would hold more than 100 products, or when several lines added together have different currencies. A single line is added to the Basket for its own currency.

If a [Saving notification handler](/v17/core-services/extending-umbcheckout.md) cancels a change, the Basket is left as it was.

#### Get

Gets the [Basket](/v17/core-services/object-reference/basket.md)

```csharp
Task<Basket> Get();
```

#### Add

Adds an item to the [Basket](/v17/core-services/object-reference/basket.md)

Parameters:

| Name | Detail                                                                            |
| ---- | --------------------------------------------------------------------------------- |
| item | [Item](/v17/core-services/object-reference/lineitem.md) to be added to the Basket |

```csharp
Task<Basket> Add(LineItem item);
```

#### Add Multiple

Adds multiple items to the [Basket](/v17/core-services/object-reference/basket.md)

Parameters:

| Name  | Detail                                                                             |
| ----- | ---------------------------------------------------------------------------------- |
| items | [Items](/v17/core-services/object-reference/lineitem.md) to be added to the Basket |

```csharp
Task<Basket> Add(IEnumerable<LineItem> items);
```

#### Reduce

Reduces the specified item by a count of 1 or removes from the [Basket](/v17/core-services/object-reference/basket.md) if only 1

Parameters:

| Name | Detail                                                                              |
| ---- | ----------------------------------------------------------------------------------- |
| key  | [Item](/v17/core-services/object-reference/lineitem.md) to be reduced in the Basket |

```csharp
Task<Basket> Reduce(Guid id);
```

#### Remove

Removes the specified item from the [Basket](/v17/core-services/object-reference/basket.md)

Parameters:

| Name | Detail                                                                                |
| ---- | ------------------------------------------------------------------------------------- |
| key  | [Item](/v17/core-services/object-reference/lineitem.md) to be removed from the Basket |

```csharp
Task<Basket> Remove(Guid id);
```

#### Remove Multiple

Removes multiple items from the [Basket](/v17/core-services/object-reference/basket.md)

Parameters:

| Name | Detail                                                                                 |
| ---- | -------------------------------------------------------------------------------------- |
| keys | [Items](/v17/core-services/object-reference/lineitem.md) to be removed from the Basket |

```csharp
Task<Basket> Remove(IEnumerable<Guid> ids);
```

#### Clear

Removes all items from the Basket and clears any set [Basket](/v17/core-services/object-reference/basket.md) cookies

```csharp
Task<Basket> Clear();
```

#### TotalItems

Returns the total quantity of every line in the Basket

```csharp
Task<long> TotalItems();
```

#### SubTotal

Returns the [Basket](/v17/core-services/object-reference/basket.md) subtotal (minus any shipping or tax)

```csharp
Task<decimal> SubTotal();
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.umbcheckout.net/v17/core-services/basket-service.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
