# add_to_cart_lines

> The lines about to be added to the cart: the add to cart forms (the main line and its add-ons at once), boxes, direct add, buy again, `addToCart`, `addBoxToCart` and `/cart/add.js`. The message of an error a filter throws shows in the form and goes out with `smootify:errors`.

Status: Ready (Smootify 2.0)  
URL: https://www.smootify.io/docs/reference/api/filters/add-to-cart-lines  
Updated: 2026-10-13

The lines about to be added to the cart: the add to cart forms (the main line and its add-ons at once), boxes, direct add, buy again, `addToCart`, `addBoxToCart` and `/cart/add.js`. The message of an error a filter throws shows in the form and goes out with `smootify:errors`.

Add it with `Smootify.addFilter`: answer the value changed, nothing to keep it, or `false` to stop.

```ts
add_to_cart_lines: ( lines: CartLineInput[], context: AddToCartContext, ) => FilterAnswer<CartLineInput[]> | Promise<FilterAnswer<CartLineInput[]>>
```

## Types

### CartLineInput

```ts
/** A line to add: `merchandiseId` is the variant gid. */
export interface CartLineInput {
  merchandiseId: string;
  quantity?: number | null;
  attributes?: AttributeInput[] | null;
  sellingPlanId?: string | null;
  parent?: { lineId?: string | null; merchandiseId?: string | null } | null;
}
```

### AddToCartContext

```ts
/** Where an addition comes from: `element` is the add to cart form, or the button that added (direct add, buy again). */
export interface AddToCartContext {
  goToCheckout: boolean;
  element?: HTMLElement | undefined;
}
```

### FilterAnswer

```ts
/** What a filter answers: the value changed, nothing (`undefined`) to keep it, `false` to stop. */
export type FilterAnswer<T> = T | false | undefined;
```
