Developer & Implementation Documentation
Complete engineering specification for the Commerce7 VIP Member Lounge bundle (vip-lounge.js), covering Shadow DOM isolation, public C7 API ingestion, session cookies, and runtime controllers.
1. Architectural Overview & Philosophy
The C7 VIP Member Lounge (vip-lounge.js) is an embeddable, standalone micro-frontend built specifically for luxury wineries powered by Commerce7.
Core Engineering Directives:
- Zero-Touch Integration: Operates without requiring winery developers or store owners to configure Commerce7 Personalization Blocks or expose sensitive C7 Application Secret Keys in clientside code.
- 100% Style Encapsulation (Shadow DOM): Injected entirely inside an isolated Shadow Root (
#c7-vip-drawer-host), guaranteeing zero CSS bleeding into or out of the host winery theme. - Single-File Zero-Dependency Bundle: Compiles to a single distribution script (~84 KB raw, ~24 KB gzipped) delivered via edge CDN.
- Native Commerce7 Session & Cart Sync: Autonomously reads Commerce7 customer session cookies, cart state, product catalogs, tasting experiences, and club tiers.
2. Technology Stack
| Layer | Technology | Rationale |
|---|---|---|
| View Layer | Preact 10 |
High performance, lightweight 3KB React alternative with modern hooks. |
| Language | TypeScript 5.x |
Strict typing for C7 API schemas, cart states, and configuration options. |
| Styling | Tailwind CSS 3.x |
Compiled and injected directly as an inline stylesheet string inside the Shadow DOM (styles.css?inline). |
| Bundler | Vite 6 (Library Mode) |
Fast builds producing an IIFE / UMD standalone bundle with zero external runtime dependencies. |
| Deployment | Cloudflare Pages |
Global edge distribution, sub-second latency, zero cold-starts. |
| Terroir Weather | Open-Meteo API |
Free, privacy-friendly, zero-API-key weather and temperature data for vineyard coordinates. |
3. How Commerce7 Integration Works
┌────────────────────────────────────────────────────────────────────────┐
│ DATA & SESSION ARCHITECTURE │
└────────────────────────────────────────────────────────────────────────┘
[ Browser Client ]
│
├─ 1. Reads Cookies / LocalStorage:
│ • `c7-customer` (Decodes customerId, firstName, isClubMember)
│ • `c7-cart` (Reads active cart ID)
│ • `c7_last_reservation` (Local booking cache)
│
├─ 2. Autonomous Public REST Queries (No App Secret Required):
│ • GET /v1/product/for-web?limit=6
│ • GET /v1/reservation-type/for-web
│ • GET /v1/club/for-web
│
├─ 3. Authenticated Member Query (If Customer Token Present):
│ • GET /v1/customer/:id/club-membership (Bearer Customer Token)
│
├─ 4. Live Actions (1-Click Operations):
│ • POST /v1/cart/item (1-Click Add to Cart)
│ • Direct Navigation to /reservation/type/:slug
│ • Direct Navigation to /club/:slug
│
└─ 5. UI Rendering inside Shadow Root (<c7-vip-drawer-host>)
3.1 Tenant Resolution Order
The library resolves the Commerce7 tenant identifier using the following priority waterfall:
data-tenant="..."attribute on the<script>tag.- Any DOM element with
[data-tenant](standard on C7 theme wrappers). window.commerce7.tenantglobal object.- Fallback default:
uncorked-by-gorilion.
3.2 Public Commerce7 APIs Utilized
All public endpoints are queried using standard tenant: <tenant-id> request headers:
- Products:
GET https://api.commerce7.com/v1/product/for-web?limit=6 - Reservations:
GET https://api.commerce7.com/v1/reservation-type/for-web→ Routes to/reservation/type/:slug - Wine Clubs:
GET https://api.commerce7.com/v1/club/for-web→ Routes to/club/:slug - Cart API:
POST https://api.commerce7.com/v1/cart/item
4. Full Script Configuration Reference (data-* Attributes)
Add any of these attributes to the <script> tag to configure the lounge:
| Attribute | Type | Default | Description |
|---|---|---|---|
data-tenant |
string |
Auto-detected | The Commerce7 tenant slug (e.g., "uncorked-by-gorilion"). |
data-position |
"bottom" | "top" | "left" | "right" |
"bottom" |
Drawer presentation layout. |
data-featured-club |
string |
First C7 Club | Slug, ID, or partial name of the club to highlight to guests (e.g., "member-s-choice-club"). |
data-brand |
string |
"YOUR PERSONAL WINE COUNTRY" |
Subtitle displayed in the top bar of the drawer. |
data-auto-open |
"true" | "false" |
"false" |
If "true", opens the drawer automatically after 400ms on initial page load. |
data-guest |
"drawer" | "login" | "hide" |
"drawer" |
Action when an unauthenticated guest clicks the trigger. |
data-host-name |
string |
"Sean" |
Name of the featured estate concierge / winemaker. |
data-host-role |
string |
"Founder & Winemaker" |
Professional title of the concierge. |
data-host-avatar |
string (URL) |
Unsplash Portrait | URL to the host's avatar image (displayed in 40x40 circle). |
data-host-email |
string |
"sean@gorilion.com" |
Concierge contact email for direct inquiry mailto links. |
data-host-note |
string |
Tier-Adaptive | Custom welcome message overriding the automated tier-specific greeting. |
data-estate-location |
string |
"Napa Valley Estate" |
Location label displayed next to live weather. |
data-estate-lat |
float |
38.2975 |
Latitude coordinate of the estate vineyard. |
data-estate-lon |
float |
-122.2869 |
Longitude coordinate of the estate vineyard. |
5. URL Query Parameters (Testing & Campaigns)
| Parameter | Values | Purpose |
|---|---|---|
?vip_position= |
bottom, top, left, right |
Overrides drawer presentation layout on the fly. |
?vip_club= |
Club slug or title | Overrides the featured wine club tier (e.g., ?vip_club=member-s-choice-club). |
?vip_reservation=true |
true |
Simulates a confirmed upcoming tasting room reservation with host Sean. |
?vip_reorder=true |
true |
Simulates the "Cellar Favorite" 1-click reorder card for returning club members. |
6. Programmatic JavaScript API (window.C7VIPDrawer)
The bundle registers a global controller on the window object:
interface C7VIPDrawerController {
open: () => void;
close: () => void;
toggle: () => void;
setPosition: (position: "bottom" | "top" | "left" | "right") => void;
setConfig: (config: Partial<DrawerConfig>) => void;
setData: (data: VIPDrawerData) => void;
getState: () => {
isOpen: boolean;
data: VIPDrawerData;
config: DrawerConfig;
isLoggedIn: boolean;
cartSummary: C7CartSummary | null;
};
}
Usage Examples:
// Open the lounge from any custom button
window.C7VIPDrawer.open();
// Switch position dynamically
window.C7VIPDrawer.setPosition('top');
// Update featured club on the fly
window.C7VIPDrawer.setConfig({ featuredClub: 'member-s-choice-club' });
// Inspect live state
console.log(window.C7VIPDrawer.getState());
Declarative DOM Triggers:
The script automatically listens for clicks on any element matching these selectors:
[data-c7-vip-trigger].c7-vip-trigger[data-vip-lounge].vip-lounge-trigger- Links with
href="#vip-lounge"orhref="#lounge"
7. Cart Collision Prevention Architecture
To prevent UI clashes between the VIP Lounge and Commerce7's native slide-out cart, the VIP Lounge:
- Listens for click events on Commerce7 cart triggers (
[data-c7-cart],.c7-cart,.c7-side-cart) and automatically closes the VIP Lounge immediately. - In
"bottom"mode, the drawer occupies the bottom half of the screen, leaving the top right side-cart completely unobstructed. - Automatically notifies visitors when a wine is added to the cart via a sleek in-drawer toast banner showing updated item count and subtotal.
Production Edge CDN: https://lounge.gorilion.com/vip-lounge.js
Live Executive Showcase: https://lounge.gorilion.com/
Live Storefront Demo: https://moderntheme.gorilion.com/lounge/
Winery Owner Guide: https://lounge.gorilion.com/owner-guide
Developer Documentation: https://lounge.gorilion.com/developer-guide