# smootify:added_to_cart

> lines were added, after the cart came back: once per add to cart, a product with its add-ons included (the main line first); when the add-ons fail, the main line that went in alone

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

lines were added, after the cart came back: once per add to cart, a product with its add-ons included (the main line first); when the add-ons fail, the main line that went in alone Since 1.x.

## Listen

```js
window.Smootify = window.Smootify || [];
window.Smootify.push((api) => {
  api.on("added_to_cart", (payload) => {
    // …
  });
});
```

## Payload

```ts
{ lines: CartLineInput[]; cart: Cart; goToCheckout: boolean }
```

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