Examples menu

๐Ÿ›’ Shopping Cart

Add items across browser tabs โ€” the cart is stored in session data and shared across every tab without cookies, localStorage, or Redux.

SESSION-scoped cart via a custom cart:{sessionId} scope means the cart is shared across every tab in your browser. Open a new tab โ€” the cart is already populated.
$app->broadcast($cartScope) pushes the updated cart to all connected tabs of that session simultaneously. No polling, no cache invalidation, no client state sync.
$c->sessionData() / setSessionData() stores the cart in the framework's per-session bucket. No static class, no manual cleanup โ€” and the cart survives a full page reload.
CSS @starting-style animates newly inserted cart rows without a single line of JavaScript. When Datastar morphs in the new item, the browser's entry transition fires automatically.
Block partial rendering โ€” on updates only the #cart-panel fragment is sent, not the product grid. The products are rendered once on initial load and stay static in the DOM.

Products

๐Ÿชฃ
Artisanal Bit Bucket (12L)
CHF 4.99
๐Ÿฆ†
Blockchain-Certified Rubber Duck
CHF 29.99
๐Ÿ“ฆ
Enterprise-Grade Left-Pad Module
CHF 1,999.00
๐Ÿ“„
Self-Documenting Code (PDF, signed)
Free!
๐Ÿ”Œ
Quantum-Entangled HDMI Cable (5m)
CHF 79.99
โญ•
Gluten-Free Null Pointer
CHF 0.01
โ˜•
Infinite Loop Coffee Mug
CHF 14.99
๐Ÿ›ก๏ธ
Zero-Day Vulnerability Insurance (Annual)
CHF 999.99

๐Ÿ›’ Cart

Your cart is empty.
Add something โ€” it persists across tabs.

๐Ÿ’ก Open a new tab and visit this page โ€” your cart will already be here.

๐ŸŽฏ Actions

addItem

Appends a product (by ?id= param) to the session cart and broadcasts to all session tabs.

removeItem

Removes a product by ?id= param and broadcasts the updated cart.

clearCart

Clears the session data key and broadcasts the empty state.

๐Ÿ‘ Views

shopping_cart.html.twig

Product grid rendered once on initial load (static). Cart panel re-renders on every broadcast via block: 'cart'.