# Smootify.addToCart()

> adds lines (through the `add_to_cart_lines` filters): resolves with the cart, or with Shopify's errors

Status: Ready (Smootify 2.0)  
URL: https://www.smootify.io/docs/reference/api/methods/addtocart  
Updated: 2026-10-13

adds lines (through the `add_to_cart_lines` filters): resolves with the cart, or with Shopify’s errors Since 1.x.

```ts
addToCart(lines: CartLineInput[], goToCheckout?: boolean): Promise<Cart | UserError[]>
```

## Types

### Cart

```ts
export interface Cart {
  /** `gid://shopify/Cart/<id>` */
  id: string;
  checkoutUrl: string;
  totalQuantity: number;
  note: string | null;
  attributes: Attribute[];
  buyerIdentity: {
    countryCode: string | null;
    email: string | null;
    phone: string | null;
    customer: {
      id: string;
      email: string | null;
      firstName: string | null;
      lastName: string | null;
      displayName: string;
    } | null;
  };
  lines: { nodes: CartLine[] };
  cost: {
    subtotalAmount: Money;
    totalAmount: Money;
    totalDutyAmount: Money | null;
    totalTaxAmount: Money | null;
    subtotalAmountEstimated: boolean;
    totalTaxAmountEstimated: boolean;
  };
  discountCodes: { code: string; applicable: boolean }[];
  appliedGiftCards: { id: string; lastCharacters: string; amountUsed: Money; balance: Money }[];
  discountAllocations: DiscountAllocation[];
}
```

### 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;
}
```

### UserError

```ts
/** An error Shopify answers (a sold-out variant, an invalid code) or a filter throws. */
export interface UserError {
  message: string;
  field?: string[] | null;
  code?: string | null;
}
```
