Skip to main content
Version: 2.0.0

Building a yStore Storefront

This guide helps you get oriented before you start writing code. yStore storefronts are built with Twig templates, Alpine.js reactivity, and SCSS for styling. Everything runs on Craft CMS.

How the pieces fit together

Request
└── Layout (global page skeleton)
└── Page template (route-level: catalog, cart, checkout, account)
└── Components (reusable feature units: product card, mini-cart)
└── Blocks (small fragments: totals row, popup shell)

Each layer overrides the one provided by yStore. You only override what you need — everything else falls through to the plugin's default templates.

What yStore gives you

WhatWhereUsed for
Twig functionscraft.yui.*Query products, get cart, format prices
Twig filtersTemplate filtersFormat dates, prices, slugs
window.yui objectGlobal JSCart ID, site context, utilities
Section data systemprivate-content-loaded eventCustomer-specific data without full page reload
Alpine.js directivesx-deferLazy-load components for performance
JavaScript eventstoggle-minicart-sidebar, etc.Cross-component communication
GraphQL APIPOST /apiHeadless / fetch-driven interactions

Common starting points

"I need to customize the product listing page" → Read Theme Architecture, then override yui/pages/catalog/products.twig

"I need to add custom data to the cart totals" → Read PHP Events → EVENT_MODIFY_CART_TOTALS

"I want to build a headless storefront" → Read GraphQL API — start with createGuestCartaddProductsToCart → checkout flow

"I need to add Alpine.js behavior to a template" → Read JavaScript & Alpine.js and Patterns

"I want to validate a custom form" → Read Form Validation

"My CSS does not override the cart/checkout styles" → Read Customizing Cart & Checkout — the plugin's stylesheets load after yours, so plain class selectors lose. The article explains all four ways around it.

Check real-life examples first

Before building something from scratch, check Real-life Examples — product listing, product detail, and checkout flows are already documented with working code.