Skip to content

E-commerce Store ​

The demo's "Maison Aurelia" store is a complete shop — home, catalog, product pages, cart, checkout — where every page is a FilamentCraft template built in the visual editor, and every product is a real row in the host app's database. The commerce sections are data-driven: authors design the layout; the data comes from your catalog at render time.

The bridge between the two is one interface. This page walks the whole build:

  1. The Storefront contract
  2. Implementing it over Eloquent
  3. Binding it
  4. Building the pages in the editor
  5. Serving the store
  6. Cart & checkout flow
  7. More than one catalog
  8. Managing the catalog in a Filament panel

1. The Storefront contract ​

FilamentCraft\Commerce\Contracts\Storefront is the only coupling point between the commerce sections and your catalog. Sections never touch your Eloquent models — they receive plain value objects and ask the contract for canonical URLs:

php
namespace FilamentCraft\Commerce\Contracts;

interface Storefront
{
    /** @return Collection<int, ProductData> */
    public function products(CatalogQuery $query): Collection;

    public function product(string $slug): ?ProductData;

    /** @return Collection<int, CategoryData> */
    public function categories(?int $limit = null): Collection;

    public function category(string $slug): ?CategoryData;

    /**
     * Canonical storefront URL for a named destination. Known names:
     * `home`, `shop`, `cart`, `checkout`, `product` (params: ['slug' => …]),
     * `category` (params: ['slug' => …]). Returns '#' for anything it cannot build.
     *
     * @param array<string, string> $params
     */
    public function url(string $name, array $params = []): string;

    /**
     * Place a cash-on-delivery order from the resolved cart lines and return the
     * result. No payment is captured.
     *
     * @param list<array{slug: string, variant: string|null, qty: int, catalog: string}> $lines
     */
    public function placeOrder(array $lines, CustomerDetails $customer): OrderResult;
}

The package ships NullStorefront as the default binding, so the commerce sections degrade to an empty state when no store is wired — you can drop them on a page before the backend exists. Its placeOrder() stores nothing and returns a random order number, so a checkout against it looks successful: bind your own store before you take orders.

The data objects ​

All in FilamentCraft\Commerce\Data, all final readonly. Prices are integer minor units (cents) throughout — no floats cross the boundary.

ObjectRole
CatalogQueryA request for products: collection (all / featured / new / category), optional categorySlug, sort, minMinor / maxMinor price window, search, limit. Named constructors: CatalogQuery::featured($limit), CatalogQuery::inCategory($slug, $limit).
ProductDataA storefront-ready product: slug, title, priceMinor, compareMinor, currencyCode, currency symbol + position, images, category name/slug, rating, reviews, description, variants, options, swatches, attributes, inStock, isNew, isFeatured, url, plus a host-owned meta bag. Derived helpers: onSale(), savePercent(), primaryImage(), badge(), meta(), and the variant helpers below.
ProductOptionData, ProductOptionValueData, VariantDataStructured options (Colour, Size) and the purchasable combinations with their own price, stock and image. See Options, variants and swatches.
ProductSwatchA colour or image chip on a product card, optionally linking to the product in that colour.
CategoryDataslug, name, image, product count, url, plus the same host-owned meta bag.
CustomerDetailsCheckout form values: name, email, phone, address, city, postal, country, note, plus the server-computed shippingMinor.
OrderResultnumber, totalMinor, itemCount, placed. OrderResult::failed() signals rejection.

Options, variants and swatches ​

A product with a single variants list of names still works, exactly as before. To give a product real options, describe them in options and list each purchasable combination in variants as a VariantData:

php
use FilamentCraft\Commerce\Data\ProductData;
use FilamentCraft\Commerce\Data\ProductOptionData;
use FilamentCraft\Commerce\Data\ProductOptionValueData;
use FilamentCraft\Commerce\Data\ProductSwatch;
use FilamentCraft\Commerce\Data\VariantData;
use FilamentCraft\Enums\ProductOptionDisplay;

new ProductData(
    slug: 'field-jacket',
    title: 'Field Jacket',
    priceMinor: 12900,
    url: '/shop/field-jacket',
    images: ['/img/jacket-olive.jpg', '/img/jacket-sand.jpg'],
    options: [
        new ProductOptionData('colour', 'Colour', [
            new ProductOptionValueData('olive', 'Olive', color: '#4b5320'),
            new ProductOptionValueData('sand', 'Sand', color: '#c2b280'),
        ], ProductOptionDisplay::Swatches),
        new ProductOptionData('size', 'Size', [
            new ProductOptionValueData('m', 'M'),
            new ProductOptionValueData('l', 'L'),
        ]),
    ],
    variants: [
        new VariantData('olive-m', options: ['colour' => 'olive', 'size' => 'm'], image: '/img/jacket-olive.jpg'),
        new VariantData('olive-l', options: ['colour' => 'olive', 'size' => 'l'], inStock: false),
        new VariantData('sand-m', options: ['colour' => 'sand', 'size' => 'm'], priceMinor: 13900, compareMinor: 15900, image: '/img/jacket-sand.jpg'),
    ],
    swatches: [
        new ProductSwatch('Olive', color: '#4b5320', image: '/img/jacket-olive.jpg', url: '/shop/field-jacket'),
        new ProductSwatch('Sand', color: '#c2b280', image: '/img/jacket-sand.jpg', url: '/shop/field-jacket'),
    ],
);
ObjectFields
ProductOptionDatakey, name, values, display (ProductOptionDisplay::Buttons, Swatches or Select)
ProductOptionValueDatakey, label, color (hex), image
VariantDatakey, label, options (option key => value key), priceMinor, compareMinor, inStock, image. A null price falls back to the product's.
ProductSwatchlabel, color (hex), image, url

ProductData resolves a variant for you, so your own views never repeat the fallback logic: variantList(), findVariant($key), variantForOptions($picks), variantLabel($key), priceFor($key), compareFor($key), savePercentFor($key), inStockFor($key) and hasStructuredVariants(). A variant without a label is labelled from its option values (Olive / M).

How it behaves:

  • The product page shows one fieldset per option and swaps price, compare price, stock note and gallery image as the shopper picks. It posts options[colour]=olive and works without JavaScript.
  • Add to cart accepts either variant=<key> or options[<option>]=<value>. When both arrive, variant wins. An unknown key or a combination with no match redirects back with the "invalid" message; a sold-out variant (or a sold-out product without variants) redirects back with the "sold out" message. Nothing is added in either case.
  • Prices are never posted. The cart stores the variant key and the server re-reads the price with priceFor() on every request, so tampering with a form cannot change what is charged. A variant you later remove (or a variant-less line of a product with VariantData variants) drops out of an existing session cart instead of falling back to the base price.
  • Order lines carry variant (the readable label) and variant_key (the raw key) for your placeOrder() to match against your own stock records.
  • Only three or six digit hex colours (#abc, #aabbcc) reach a style attribute; any other value renders as a label-only chip.
  • Turn on Show colour swatches on the Product listing or Product carousel to show up to five swatches on each card, then a +N link to the product. A swatch with a url is a link; one without is a button. Hovering, focusing or (for a button) tapping a swatch that has an image previews that photo on the card.
  • A swatch url can preselect the product page: ?colour=olive (an option key with a value key) picks the first in-stock variant in that colour, and ?variant=olive-m picks one variant by its key. Unknown keys or values are ignored, and the page falls back to the first in-stock variant.
  • A product with VariantData variants (with or without options) needs a choice before it can be bought, so its card shows a Choose options link to the product page instead of the quick-add button, and cart/add without a variant sets the "invalid" message.

2. Implementing it over Eloquent ​

The demo's implementation maps three ordinary models (Product, Category, Order) onto the contract. The product model is nothing special — casts and a couple of scopes:

php
<?php

declare(strict_types=1);

namespace App\Models;

use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;

class Product extends Model
{
    protected function casts(): array
    {
        return [
            'price' => 'decimal:2',
            'compare_at_price' => 'decimal:2',
            'rating' => 'float',
            'images' => 'array',
            'variants' => 'array',
            'attributes' => 'array',
            'in_stock' => 'boolean',
            'is_featured' => 'boolean',
            'is_new' => 'boolean',
        ];
    }

    public function category(): BelongsTo
    {
        return $this->belongsTo(Category::class);
    }

    public function scopeFeatured(Builder $query): void
    {
        $query->where('is_featured', true);
    }

    public function scopeNewArrivals(Builder $query): void
    {
        $query->where('is_new', true);
    }
}

The storefront translates CatalogQuery into an Eloquent query and everything Eloquent into value objects:

php
use App\Enums\OrderStatus;
use App\Models\Order;
use App\Models\Product;
use FilamentCraft\Commerce\Contracts\Storefront;
use FilamentCraft\Commerce\Data\CatalogQuery;
use FilamentCraft\Commerce\Data\CustomerDetails;
use FilamentCraft\Commerce\Data\OrderResult;
use FilamentCraft\Commerce\Data\ProductData;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Support\Collection;
use Illuminate\Support\Facades\DB;

final class EloquentStorefront implements Storefront
{
    private const SYMBOL = '€';

    private const POSITION = 'before';

    private const BASE = '/store';

    public function products(CatalogQuery $query): Collection
    {
        $builder = Product::query()->with('category');

        if ($query->collection === 'featured') {
            $builder->featured();
        } elseif ($query->collection === 'new') {
            $builder->newArrivals();
        }

        if ($query->categorySlug !== null && $query->categorySlug !== '') {
            $builder->whereHas('category', fn (Builder $c) => $c->where('slug', $query->categorySlug));
        }

        // Optional carousel filters, plus any collection you registered with catalogCollections()
        $builder->when($query->tag, fn (Builder $b, string $tag) => $b->whereJsonContains('tags', $tag));
        $builder->when($query->brand, fn (Builder $b, string $brand) => $b->where('brand', $brand));
        $builder->when($query->collection === 'sale', fn (Builder $b) => $b->whereNotNull('compare_at_price'));

        // … price window + search filters trimmed

        match ($query->sort) {
            'price-asc' => $builder->orderBy('price'),
            'price-desc' => $builder->orderByDesc('price'),
            'rating' => $builder->orderByDesc('rating'),
            default => $builder->orderBy('position')->orderBy('id'),
        };

        if ($query->limit !== null && $query->limit > 0) {
            $builder->limit($query->limit);
        }

        return $builder->get()->map(fn (Product $p): ProductData => $this->toProductData($p))->values();
    }

    public function product(string $slug): ?ProductData
    {
        $product = Product::query()->with('category')->where('slug', $slug)->first();

        return $product instanceof Product ? $this->toProductData($product) : null;
    }

    /**
     * @param array<string, string> $params
     */
    public function url(string $name, array $params = []): string
    {
        return match ($name) {
            'shop' => self::BASE.'/shop',
            'cart' => self::BASE.'/cart',
            'checkout' => self::BASE.'/checkout',
            'product' => self::BASE.'/p/'.($params['slug'] ?? ''),
            'category' => self::BASE.'/shop?category='.urlencode($params['slug'] ?? ''),
            default => self::BASE,
        };
    }

    /**
     * @param list<array{slug: string, variant: string|null, qty: int, catalog: string}> $lines
     */
    public function placeOrder(array $lines, CustomerDetails $customer): OrderResult
    {
        return DB::transaction(function () use ($lines, $customer): OrderResult {
            $items = [];
            $subtotal = 0;

            foreach ($lines as $line) {
                $product = Product::query()->where('slug', $line['slug'])->first();

                if (! $product instanceof Product) {
                    continue;
                }

                $unit = $this->minor((string) $product->price);
                $qty = max(1, $line['qty']);
                $subtotal += $unit * $qty;

                // … order-item row assembly trimmed
            }

            if ($items === []) {
                return OrderResult::failed();
            }

            $order = Order::query()->create([
                'number' => $this->orderNumber(),
                'status' => OrderStatus::Pending,
                'customer_name' => $customer->name,
                // … remaining customer + totals columns trimmed
                'subtotal' => $subtotal,
                'shipping' => $customer->shippingMinor,
                'total' => $subtotal + $customer->shippingMinor,
                'payment_method' => 'cod',
                'placed_at' => now(),
            ]);

            $order->items()->createMany($items);

            return new OrderResult(
                number: $order->number,
                totalMinor: (int) $order->total,
                itemCount: array_sum(array_column($items, 'qty')),
            );
        });
    }

    private function toProductData(Product $product): ProductData
    {
        return new ProductData(
            slug: $product->slug,
            title: $product->name,
            priceMinor: $this->minor((string) $product->price),
            currencySymbol: self::SYMBOL,
            symbolPosition: self::POSITION,
            // … image / variant / attribute mapping trimmed
            inStock: (bool) $product->in_stock,
            url: $this->url('product', ['slug' => $product->slug]),
        );
    }

    // … categories(), category(), minor(), image helpers trimmed
}

Two details worth copying:

  • placeOrder() re-reads prices from the database inside a transaction. The lines it receives carry only slugs and quantities — never prices — so nothing a customer submits can influence what they're charged.
  • url() returns your canonical paths. Every "View product", "Go to cart", and category link in every commerce section routes through it, so the sections never hard-code a URL scheme. Return root-relative paths (/shop/cart): after Add to cart the shopper is sent to url('cart') only when it starts with /, and a full https:// URL falls back to the previous page.
  • The Illuminate\Support\Collection import is not optional. The contract's products() / categories() return types reference it, so omitting the use line is a fatal "return type must be compatible" error the moment the class loads.

When your catalog isn't retail ​

ProductData's typed properties are physical-goods vocabulary — inStock, compareMinor, variants, rating. A catalog of courses, events, or memberships carries fields none of them describe. Two escape hatches, in the order you should reach for them.

1. Put the extra fields in meta. A host-owned bag on both ProductData and CategoryData, carried through untouched; nothing in the package inspects it.

php
return new ProductData(
    slug: $course->slug,
    title: $course->title,
    priceMinor: $this->minor((string) $course->price),
    url: $this->url('product', ['slug' => $course->slug]),
    meta: [
        'seats_left' => $course->seats_left,
        'schedule' => $course->schedule_label,
        'plans' => $course->pricingPlans,
    ],
);

Read it back with $product->meta('seats_left'), or $product->meta('branch', 'main') for a default.

2. Swap the card, keep the section. The value of the built-in listings is the grid, filters, pagination, mobile filter sheet and empty state — not the card. Point one config key at your own Blade view and the product listing, the carousel and the related-products rail all render it:

php
// config/filamentcraft.php
'commerce' => [
    'card_view' => 'storefront.course-card',
],

Your view receives the same variables the built-in card gets — $product, $locale, $t (a translation closure), $storeKey, $cartUrl, $showAdd, $catalogKey — so the quick-add form keeps working if you copy it across. Start from vendor/filamentcraft/filamentcraft/resources/views/sections/partials/product-card.blade.php. A view path that doesn't exist falls back to the built-in card rather than breaking every product page.

Between the two, one unfamiliar domain field costs a card override rather than a fork of the listing, the detail page and the cart.

What the built-in sections actually read ​

Populate what you need; the rest can stay at its default.

PropertyWhere it shows
slugAdd-to-cart payload, editor preview navigation targets
title, urlCard and detail heading + links
priceMinor, compareMinor, currencySymbol, symbolPositionEvery price; compareMinor > priceMinor drives the sale badge and savePercent()
imagesCard media (primaryImage()) and the detail gallery
inStock, isNewThe single corner badge, via badge()
categoryNameCard eyebrow
rating, reviewsStar row
descriptionDetail body
variants, optionsDetail variant picker, price and stock per variant
swatchesCard colour chips (Show colour swatches)
attributesDetail spec table (label ⇒ value)
currencyCodeProduct JSON-LD only (ISO 4217; without it the schema falls back to a symbol guess)
categorySlug, isFeaturedNever rendered — they exist for CatalogQuery filtering

CategoryData renders name, image, count and url; slug drives the category filter.

3. Binding it ​

One line in a service provider:

php
use App\Storefront\EloquentStorefront;
use FilamentCraft\Commerce\Contracts\Storefront;

class AppServiceProvider extends ServiceProvider
{
    public function boot(): void
    {
        // Wire FilamentCraft's e-commerce sections to this app's catalog. Bound in
        // boot() so it overrides the package's NullStorefront default regardless of
        // provider registration order.
        $this->app->singleton(Storefront::class, EloquentStorefront::class);
    }
}

The boot() placement is deliberate: the package registers NullStorefront in its own provider, and binding in your boot() guarantees you win the container regardless of provider order.

Your own collections and filters ​

The product carousel's Show picker offers featured, new, all and one category. Add your own collections, and the carousel also has optional Tag and Brand fields; all of them reach products() on the CatalogQuery:

php
FilamentCraftPlugin::make()->catalogCollections([
    'sale' => 'On sale',
    'gifts' => fn (): string => __('shop.collections.gifts'),
]);

Read $query->collection, $query->tag and $query->brand in your products() (see the filters above). Unknown collections should fall back to "all".

4. Building the pages in the editor ​

With the binding in place, seven built-in sections turn the editor into a store builder (see Built-in Sections for their full setting schemas):

SectionSlugRenders
StoreHeroSectionstore-heroStore landing hero with shop CTAs
ProductListingSectionproduct-listingFilterable/sortable catalog grid (the /shop page)
ProductDetailSectionproduct-detailGallery, price, variants, add-to-cart form
ProductCarouselSectionproduct-carouselA CatalogQuery-driven product strip (featured, new, per-category)
CategoryGridSectioncategory-gridCategory cards with product counts
CartSectioncartLine items, quantity forms, totals
CheckoutSectioncheckoutCustomer form, shipping rules, order summary, confirmation

The demo store is five templates, each assembled from these plus the ordinary content sections: home (store-hero + carousels + category grid), shop (product-listing), product (product-detail), cart, and checkout. Authors configure selection, not data — a carousel's settings say "featured, limit 8", and the products themselves always come from the bound Storefront at render time. Add a product in the database and it appears everywhere, no republish needed.

All seven declare cacheable(): false and are excluded from the rendered-fragment cache. The listing, detail, cart and checkout sections depend on per-request state (the URL's filters and product slug, the visitor's session). The hero, carousels and category grid read live catalog data, so a newly added product shows up on the next request. See Caching.

5. Serving the store ​

The demo mounts the store under a fixed /store prefix, registered before the tenant catch-alls so store is never read as a team slug:

php
Route::prefix('store')->name('store.')->group(function (): void {
    Route::get('/', [EcommercePublicController::class, 'home'])->name('home');
    Route::get('shop', [EcommercePublicController::class, 'shop'])->name('shop');
    Route::get('cart', [EcommercePublicController::class, 'cart'])->name('cart');
    Route::get('checkout', [EcommercePublicController::class, 'checkout'])->name('checkout');
    Route::get('p/{product}', [EcommercePublicController::class, 'product'])->name('product');
});

One template, every product ​

The interesting route is p/{product}. There is one product template — the URL's slug rides into the render as a RenderContext parameter, and ProductDetailSection resolves the live product from it:

php
use FilamentCraft\Models\Site;
use FilamentCraft\Models\Template;
use FilamentCraft\Rendering\TemplateRenderer;
use FilamentCraft\Routing\RenderContext;

final class EcommercePublicController extends Controller
{
    public function __construct(private readonly TemplateRenderer $renderer) {}

    public function product(Request $request, string $product): Response
    {
        return $this->renderTemplate($request, 'product', new RenderContext(parameters: ['product' => $product]));
    }

    private function renderTemplate(Request $request, string $slug, ?RenderContext $context = null): Response
    {
        $site = $this->site();

        app()->instance(Site::class, $site);

        // … session-persisted ?lang= locale resolution trimmed

        $template = Template::query()
            ->forSite($site->id)
            ->published()
            ->where('slug', $slug)
            ->first();

        abort_if($template === null, 404);

        $html = $this->renderer->render($template, 'published', $locale, $context);

        return response($html);
    }
}

This is the standard dynamic-pages pattern: RenderContext carries route parameters (strings) and bindings (objects) into the section layer. In the editor, where no URL parameter exists, the section falls back to an author-chosen preview product so the canvas still shows a real layout.

Expected result: /store renders the published home template with real catalog rows in every carousel and grid, /store/shop lists the filterable catalog, and /store/p/{slug} shows that product's detail page — every product through the one product template.

6. Cart & checkout flow ​

The cart is deliberately JS-free: every mutation is a plain HTML form POST that redirects back. No client runtime, no hydration, nothing to break when the visitor blocks scripts — and no Livewire on the public page.

The cart itself lives in the server session — no cookies of its own, no localStorage. FilamentCraft\Commerce\CartService owns the session payload: it stores catalog/slug/variant/quantity lines and re-resolves each line against its catalog (the bound Storefront unless you registered more) on every read, so prices are never persisted client-side or server-side.

Every cart form also posts a store key that namespaces the session cart. The commerce sections use the rendering site's slug (falling back to default, which the controller also assumes when the field is absent) — so two sites served by the same host app keep fully independent carts within one visitor session.

The endpoints are always registered by the package (independent of the public_routes config, since hosts often own their public routing), under the web middleware group for session + CSRF:

php
Route::middleware(['web'])->prefix('filamentcraft/cart')->name('filamentcraft.cart.')->group(function (): void {
    Route::post('add', [CartController::class, 'add'])->name('add');
    Route::post('update', [CartController::class, 'update'])->name('update');
    Route::post('remove', [CartController::class, 'remove'])->name('remove');
    Route::post('checkout', [CartController::class, 'checkout'])->name('checkout');
});

The commerce sections render the matching forms; you never build them yourself. Security properties of the flow:

  • Prices are never trusted from the client. Forms post a product slug and quantity; the controller resolves the product from the bound Storefront on every request. The cart stores slugs, and checkout re-resolves the whole cart before charging — a product deleted (or repriced) after add-to-cart is handled server-side.

  • Shipping settings are HMAC-signed. The checkout section's author-configured flat fee and free-shipping threshold travel as hidden inputs, because the cart routes are site-agnostic and the server can't look the section's settings up on POST. The checkout view emits them next to the customer fields:

    blade
    <input type="hidden" name="shipping_flat" value="{{ $flat }}">
    <input type="hidden" name="free_threshold" value="{{ $threshold }}">
    <input type="hidden" name="site" value="{{ $siteKey }}">
    <input type="hidden" name="shipping_expires" value="{{ $expires }}">
    <input type="hidden" name="shipping_sig" value="{{ \FilamentCraft\Commerce\ShippingSignature::sign($flat, $threshold, $storeKey, $siteKey, $cart->catalogKeys($storeKey), $expires) }}">

    FilamentCraft\Commerce\ShippingSignature signs the fee and threshold together with the store key, the site id, the catalogs in the cart and an expiry (24 hours, from ShippingSignature::expiry()), and checkout verifies it. Editing the hidden fields in devtools can't zero out the shipping charge, and because zero values are signed too, stripping the fields fails verification as well. A form from one site can't be replayed against another site's store, and an old form stops working once it expires. Checkout also checks that the posted site owns the store key.

    If you published and customised sections/checkout.blade.php, add the site and shipping_expires inputs and the new sign() arguments shown above.

  • Redirects are local-only. The return URL a form posts is accepted only as a same-site absolute path, so the cart can't be used as an open redirect.

When the order passes validation, the controller hands the resolved lines and a CustomerDetails to your Storefront::placeOrder(), records a confirmation snapshot in the session, and redirects back to the checkout page with ?placed={number} — which the checkout section renders as the order-confirmation state.

Expected result: submitting a valid checkout form lands back on /store/checkout?placed=XXXX, the checkout section swaps to its confirmation panel (order number, line items, totals), the cart is emptied, and an Order row with its items exists in the database with status pending.

Hand off to a payment provider ​

The built-in checkout takes the order and leaves payment to you (cash on delivery, invoice). To take payment online — Mollie, Stripe Checkout, PayPal — create a pending order in placeOrder(), open a payment session with your provider, and return OrderResult::redirect() with the provider's checkout URL:

php
use FilamentCraft\Commerce\Data\OrderResult;
use Mollie\Laravel\Facades\Mollie;

public function placeOrder(array $lines, CustomerDetails $customer): OrderResult
{
    $order = $this->createPendingOrder($lines, $customer);

    $payment = Mollie::api()->payments->create([
        'amount' => ['currency' => 'EUR', 'value' => number_format($order->total_minor / 100, 2, '.', '')],
        'description' => 'Order '.$order->number,
        'redirectUrl' => route('payment.return', $order),
        'webhookUrl' => route('mollie.webhook'),
        'metadata' => ['order' => $order->number],
    ]);

    return OrderResult::redirect($order->number, $payment->getCheckoutUrl(), $order->total_minor, count($lines));
}

The controller still records the confirmation snapshot and empties the cart, then sends the shopper to the URL. Point the provider's return URL at a route of yours that checks the payment: when it succeeded, redirect to your checkout page with ?placed={number} and the checkout section shows the confirmation; when it failed or was cancelled, show a page that retries the payment for the same pending order (the cart is already empty). Mark the order paid from the provider's webhook, not from the return. Only absolute http and https URLs are followed (an internationalised host such as bücher.de is sent in its xn-- form) — anything else falls back to the normal confirmation — and checkout from the editor preview never reaches placeOrder().

Use your own checkout page ​

If checkout already exists in your app (Cashier, a Livewire page, a hosted payment page), skip the built-in one entirely. Return your route from url('checkout') and leave the Checkout section off your pages:

php
public function url(string $name, array $params = []): string
{
    return match ($name) {
        'cart' => '/cart',
        'checkout' => route('checkout.show'),
        default => '#',
    };
}

The Cart section's checkout button links straight to that URL. placeOrder() is never called, because the shopper never reaches the package's checkout form; your page reads the cart through CartService::resolve() (lines, variant keys and quantities) and takes the order itself. Add to cart still posts to the package cart, and the prices shown there are re-read from your catalog on every request. If you only need payment hosted elsewhere, keep the built-in checkout and use the payment hand-off instead.

Cart badge and toasts from your own components ​

The built-in cart is a plain form post, so its badge is right on every page load. When your own Livewire component changes the cart without a navigation, dispatch the package's events and the built-in header and toast host answer them:

php
use FilamentCraft\Commerce\CartEvents;

$this->dispatch(CartEvents::UPDATED, count: $cart->count(), store: $site->slug);
$this->dispatch(CartEvents::TOAST, message: __('Added to your cart'));

Every [data-fc-cart-count] badge updates (a badge with data-fc-cart-store only follows its own store), and the toast appears in <x-filamentcraft::toast-host />, so put that component in your layout once. A plain CustomEvent dispatched on window, document or any element works the same way.

The toast payload takes a tone (type works too) and an optional action link:

php
$this->dispatch(CartEvents::TOAST,
    message: __('Added to your cart'),
    tone: 'ok',
    action: ['label' => __('View cart'), 'url' => route('cart')],
);
  • tone is ok (the default), info or err; error and danger count as err. Errors are announced with role="alert" and stay 2 seconds longer.
  • action.url must start with / or http(s)://. Anything else, such as javascript: or //host, is dropped and the toast shows without the link.
  • Sending the same message again while it is still showing adds a ×2 count to that toast and restarts its timer. It does not add a second toast.
  • The timer pauses while the visitor hovers or focuses the stack, while they drag a toast, and while the tab is in the background. A bar along the bottom of each toast shows the time left.
  • A visitor can close a toast with its close button, by swiping it more than 72px sideways, or with Escape, which closes the newest one.

The component takes three props:

PropDefaultNotes
:life4500Milliseconds before a toast closes itself. Errors get 2000 more.
:max3Toasts shown at once. The oldest closes when another arrives.
positionbottom-endbottom-end, bottom-start, bottom-center, top-end, top-start or top-center.
blade
<x-filamentcraft::toast-host :life="6000" :max="2" position="top-center" />

On a phone the stack spans the screen width. From 640px up each toast is 23rem wide, placed by position. start and end follow the page direction, so an RTL page needs no extra setting. The stack sits above the bottom navigation (--fc-bottom-chrome) and the safe-area insets, and takes its colors and corner radius from the site theme.

Driving the mobile filter sheet from your own script ​

The product listing's mobile filter sheet opens from a hidden checkbox, so it works with JavaScript off. If you render the sheet yourself and open it from Alpine or a teleported button, toggle the is-open class instead:

blade
<div class="fc-filter-sheet" x-bind:class="filtersOpen && 'is-open'">…</div>

The mobile filter bar hides itself from 1024px up, so it needs no lg:hidden.

7. More than one catalog ​

A sports academy sells courses, events and kit — three catalogs, one cart. Keep binding Storefront for the one you already have (it is always the products catalog), and register the others as FilamentCraft\Commerce\Contracts\Catalog implementations:

php
interface Catalog
{
    public function key(): string;      // 'courses' — what sections store
    public function label(): string;    // 'Courses' — what the editor shows
    public function items(CatalogQuery $query): Collection;    // Collection<int, ProductData>
    public function item(string $slug): ?ProductData;
    public function categories(?int $limit = null): Collection; // Collection<int, CategoryData>
    public function category(string $slug): ?CategoryData;
    public function url(string $name, array $params = []): string;
}

The methods mirror the Storefront read side, and they return the same ProductData / CategoryData — so the built-in cards, grids, filters and detail page render a course the way they render a lamp. Carry the course-only fields in meta, and swap the card if they need showing (When your catalog isn't retail). The sections ask url() for shop only (the "view all" and "back" links); product and category links come from each item's own url. Cart and checkout URLs stay with the Storefront, since there is one cart.

Register them on the plugin, or list the classes in config:

php
FilamentCraftPlugin::make()
    ->catalogs([
        CourseCatalog::class,          // resolved from the container
        new EventCatalog($calendar),   // or an instance
    ]);
php
// config/filamentcraft.php
'commerce' => [
    'catalogs' => [CourseCatalog::class, EventCatalog::class],
],

A host catalog registered under the key products replaces the Storefront adapter.

Pick a catalog per section ​

Once more than one catalog is registered, the product listing, product carousel, product detail, category grid and store hero each gain a Catalog select, defaulting to products. A course page is then a template with a product-detail section pointed at courses — no new section class. With a single catalog the select stays hidden and every section reads the Storefront exactly as before.

A section pointed at a catalog you later remove renders its empty state rather than erroring, and php artisan filamentcraft:doctor lists the registered catalogs and warns about any published section whose catalog is gone.

Cart routing and placeOrder() ​

Every add-to-cart form posts the section's catalog key beside the slug. The controller resolves the item — and its price — from that catalog on the server, and the cart line remembers the key, so one basket can hold a lamp and a course. Lines stored before catalogs existed carry no key and resolve as products.

placeOrder() still lives on your Storefront, and each line now names its catalog:

php
public function placeOrder(array $lines, CustomerDetails $customer): OrderResult
{
    foreach ($lines as $line) {
        match ($line['catalog']) {
            'courses' => $this->enrol($line['slug'], $line['qty'], $customer),
            'events' => $this->book($line['slug'], $line['qty'], $customer),
            default => $this->ship($line['slug'], $line['variant'], $line['qty'], $customer),
        };
    }

    // …
}

A single-catalog store can ignore the key: it is always products.

In the editor: a product-detail section pointed at courses previews the course named by ?product= (or its own Preview product pick, which lists that catalog's items). A link clicked inside the preview still opens the first page that holds a product-detail section, whatever its catalog — pick the course page from the page switcher when you have both.

8. Managing the catalog in a Filament panel ​

The demo runs the whole store from one panel: FilamentCraft's editor and custom catalog resources side by side. Nothing special is required — FilamentCraft is a plugin like any other, and your Product / Category / Order resources are ordinary Filament resources:

php
class ShopPanelProvider extends PanelProvider
{
    public function panel(Panel $panel): Panel
    {
        return $panel
            ->id('shop')
            ->path('shop')
            ->login()
            ->brandName('Maison Aurelia')
            ->tenant(Workspace::class, slugAttribute: 'slug')
            ->plugin(
                FilamentCraftPlugin::make()
                    ->navigationGroup('Storefront')
                    ->mirrorEditorStyles()
                    ->publicUrlUsing(fn (Template $template): ?string => $this->storefrontUrl($template))
            )
            ->discoverResources(in: app_path('Filament/Shop/Resources'), for: 'App\Filament\Shop\Resources')
            // … pages/widgets/middleware trimmed
            ;
    }
}

navigationGroup('Storefront') files FilamentCraft's items under their own sidebar group, next to the panel's Products / Categories / Orders groups. The publicUrlUsing() closure maps templates to their /store/... URLs so the editor's "open live" pill works (the product template points at a representative product, since one template serves them all). The result: a store manager edits the storefront design, curates the catalog, and processes orders without leaving /shop.