# Using your own cart

> For a theme cart, a custom cart or a headless storefront: what Luxe does without its drawer, set and gift lines, rewards, members and the events to use.

Source: https://www.luxesets.com/docs/own-cart

## Theme cart or Luxe cart

Luxe works with the theme's own cart (the default) or replaces it with the Luxe cart drawer, a merchant setting in the app ([The Luxe cart](https://www.luxesets.com/help/the-luxe-cart)). Checkout is the same in both: set prices and ladder rewards come from Shopify Functions, whatever renders the cart.

|                                    | Theme cart (default)                                                              | Luxe cart drawer                   |
| ---------------------------------- | --------------------------------------------------------------------------------- | ---------------------------------- |
| Set prices and rewards at checkout | Yes                                                                               | Yes                                |
| Ladder progress and gift choice    | Where the merchant places the **Rewards bar** block (Full layout for gift choice) | Built in                           |
| Edit set                           | Added by Luxe on the theme's cart page, with no code                              | Built in                           |
| Gift removed when its rung is lost | Only where a Rewards bar is on the page                                           | Always                             |
| `window.Luxe.cart`                 | `undefined`                                                                       | `register`, `hideLines`, `refresh` |
| `luxe:*` DOM events                | Yes, except the drawer's own                                                      | Yes                                |

So with a theme cart, check `window.Luxe?.cart` before calling it, and use the [DOM events](https://www.luxesets.com/docs/storefront-api#events) instead: they fire in both modes.

## What the cart holds

Everything Luxe adds is an ordinary Shopify cart line with `_luxe_*` line properties, which themes hide because they start with `_` ([Line properties](https://www.luxesets.com/docs/line-properties#props)).

| Line                         | In `/cart.js`                                                                                                                                                                                                                   |
| ---------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Build-your-own or Fixed set  | One line for the set product, with `_luxe_kit` (and `_luxe_slots` for a Build-your-own set). After the Cart Transform, Liquid lists its components in `item.item_components`; the visible **Includes** property lists the picks |
| Collection set               | One line per item, all sharing one `_luxe_kit_group` value                                                                                                                                                                      |
| A set bought on subscription | One line per item on its selling plan, sharing one `_luxe_kit_group` value ([Subscription sets](https://www.luxesets.com/docs/subscription-sets#cart))                                                                          |
| Reward gift                  | A line with `_luxe_gift`                                                                                                                                                                                                        |
| Upsell or checkout offer     | Lines with `_luxe_addon`                                                                                                                                                                                                        |

- **Prices are Shopify's.** Line prices, discount allocations and totals in `/cart.js` come after the Cart Transform and the Discount Function ran. Luxe's builder, tray and bar predict; only the Functions change prices. Show Shopify's numbers.
- **Never edit `_luxe_*` values.** The Functions never trust a property for price and re-validate every set; an invalid build sells unexpanded at the set product's own price.
- **Treat a `_luxe_kit_group` as one set** when you show, change or remove its lines.
- **Set contents and Edit set** in a custom line-item loop: [Theme code recipes](https://www.luxesets.com/docs/theme-recipes#contents).

## Rewards and gifts

- **Money and free shipping rungs** need no cart code: the Luxe Rewards discount applies them. A money reward shows in Shopify's cart as a discount allocation; free shipping applies at checkout.
- **Progress and gift choice** come from the **Rewards bar** theme app block. On the cart page the merchant adds it in the theme editor; in a theme's own drawer, where app blocks cannot go, use the [Rewards bar recipe](https://www.luxesets.com/docs/theme-recipes#bar).
- **Gifts are never added without the shopper's tap.** A chosen gift is a line with `_luxe_gift`, free only while its rung holds. A Rewards bar on the page removes it when the rung is lost; without one, checkout charges it at its own price.
- **Members' teaser.** Placed **By the checkout button**, it appears under the theme's checkout button on the cart page, and in a theme drawer that shows the Rewards bar.

## Keeping the cart in step

| Need                                                                              | Use                                                                                                                                                                    |
| --------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Re-render the theme cart after Luxe changes it                                    | `luxe:cart:updated` (`{ itemCount, totalPrice, lines }`), after every cart read Luxe makes                                                                             |
| Open the theme's drawer instead of going to `/cart` after a set is added          | Call `preventDefault()` on `luxe:kit:added`                                                                                                                            |
| Tell Luxe the cart changed outside `/cart/*.js` (the Storefront API, for example) | Dispatch `luxe:cart:request-refresh` on `document`. Changes through `/cart/add.js`, `/cart/change.js`, `/cart/update.js` and `/cart/clear.js` are noticed on their own |

A complete script for Dawn, Horizon and two premium theme families, with loop protection: [Keep a theme cart in step](https://www.luxesets.com/docs/theme-recipes#events).

## Members

Member prices need no cart code either: for a signed-in member, Shopify's cart already carries them. No line property, `luxe:*` event or `window.Luxe.cart` member says a line is member-priced. Details: [Members and member pricing](https://www.luxesets.com/docs/members#theme-cart).

## Headless and mobile

A storefront without the theme has no app embed, so no Luxe component, DOM event or customer event runs there:

- Read live sets and the published ladder from the [bundle set endpoint](https://www.luxesets.com/docs/http-api#endpoint), and predict prices from it, as the [Tapcart blocks](https://www.luxesets.com/docs/tapcart) do.
- Add sets with the same `_luxe_*` line properties as the theme ([Line properties](https://www.luxesets.com/docs/line-properties#props)). The Functions price and re-validate every build at checkout, so a client needs no signature.
- A headless cart reads no customer for Luxe, so show the public ladder and guest prices; checkout gives members more, never less.
