doc-site
Developer guide

Cart and membership pass

The live cart section, the JavaScript behind its buttons, the membership pass request, and the disabled cart code that still sits beside it.

The cart page renders theme/sections/asc-new-cart-layout.liquid. Its buttons are handled by src/js/custom.js, compiled into custom.bundle.js, which loads on every page.

Which cart code is live

theme/templates/cart.json contains three sections:

SectionState
asc-new-cart-layoutEnabled. This is the cart
asc-cart-itemsDisabled. It renders snippets/camp-cart-item.liquid and snippets/asc-cart-actions.liquid
main-cart-footerDisabled

snippets/asc-cart-actions.liquid is what documentation/MEMBERSHIP.md describes. A change there has no effect unless someone re-enables "ASC Items" in the theme editor.

The Dawn cart drawer renders only when the theme setting Cart type is drawer. It is currently notification, and the header links straight to /cart.

Line rendering

For each cart line, asc-new-cart-layout.liquid checks the product tags:

TagsRendered as
Includes sportCamp card inside div.asc-camp.cart-item, with participant details and the membership pass link
Includes sport and membership-pass-productCamp card, pass link hidden and title not linked
No sportsnippets/product-cart-item.liquid, with quantity buttons

Each camp wrapper carries data-variant-id and data-line-item-attributes. The attributes are JSON built by hand in Liquid, so custom.js parses them with sanitizeAndParseJson, which decodes HTML entities and escapes control characters. A double quote typed into a participant text area can still make the JSON invalid.

The section works out the link's state inside its line loop, then renders one a.asc-camp-login per camp. The states are in Membership passes.

Class on .asc-camp-loginHandler in custom.js
use-membership-passCalls the pass service
membership-pass-not-applicableShows a SweetAlert explaining passes only apply to ASC camps
NeitherOrdinary link to the login page

data-visible='false' hides the link through CSS.

Use membership pass request

On click of .use-membership-pass:

  1. Add loading to the closest .cart-item.

  2. GET {Shopify.routes.cart_url}.js to read the cart token.

  3. Build the payload:

    {
      "customer_id": 1234567890,
      "customer_email": "parent@example.com",
      "token": "<cart token>",
      "lineItem": {
        "variantId": "<data-variant-id>",
        "attributes": { "First Name": "…" }
      }
    }
  4. POST {window.theme.api.root}v1/customers/{customer_id}/membership-pass/use with Content-Type: text/plain and the body btoa(btoa(JSON.stringify(payload))).

  5. On success, set the cart cookie to data.newCartToken for 11 days, show "Membership Pass has been used for this booking" and reload.

  6. On failure, show "That didn't work..." with the service's message, then reload.

The service response is { status, message, data }. The messages a customer can see include "Pass already applied for this line item", "Line item not found in cart" and "Customer has no camp claims remaining".

btoa rejects characters above U+00FF, so a participant property containing one fails before the request is sent.

Other cart handlers in custom.js

SelectorAction
.increase-quantity, .decrease-quantity, quantity inputsPOST {cart_change_url}.js with { id, quantity }, then reload
.remove-line-itemSweetAlert confirmation, then quantity 0 and reload
.asc-cart-checkout-buttonHandled by theme/assets/cart-layout.js, which submits the hidden #checkout button

theme/snippets/asc-track-checkout.liquid publishes checkout_clicked through Shopify.analytics.publish when the checkout button is clicked. theme/assets/clarity-tracking.js writes clarity_uid and clarity_session_id cart attributes once per session.

Upsell

asc-new-cart-layout.liquid loops over the cart lines and keeps the last variant Upsell Product that is available and not already in the cart. The block renders when the section's Upsell Visible setting is ticked.

Pending change

Branch 96-asc-073-fx-au-memberships-revised-cart-messaging-and-info-box in the theme, with 95-asc-073-… in asc-shopify-src, rewrites the state logic in both the live section and asc-cart-actions.liquid, adds a membership-pass-no-pass class and a membership_pass.use_membership_pass_no_pass string, and updates custom.js. Rebase any cart change onto that work if it has merged.

Source map

ConcernFile
Live carttheme/sections/asc-new-cart-layout.liquid
Cart CSSsrc/css/new-cart-layout.css
Click handlerssrc/js/custom.js
Checkout buttontheme/assets/cart-layout.js, theme/snippets/asc-track-checkout.liquid
Wordingtheme/locales/en.default.json, membership_pass.*
Disabled carttheme/sections/asc-cart-items.liquid, theme/snippets/camp-cart-item.liquid, theme/snippets/asc-cart-actions.liquid
Pass serviceasc-api-membership-pass repository, src/services/redemption.service.ts

On this page