Overview
The ShelfWise storefront allows you to enable e-commerce capabilities for any shop in your tenant. Each shop can have its own storefront with customizable settings, branding, and product catalog.
Enabling the Storefront
Storefronts are enabled at the shop level using the storefront_enabled flag:
// app/Models/Shop.php:22
$shop -> update ([
'storefront_enabled' => true ,
'storefront_settings' => [
'theme_color' => '#3b82f6' ,
'logo_url' => 'https://example.com/logo.png' ,
'banner_url' => 'https://example.com/banner.jpg' ,
'about_text' => 'Welcome to our store!' ,
'contact_email' => '[email protected] ' ,
'shipping_policy' => 'We ship within 2-3 business days.' ,
'return_policy' => '30-day return policy applies.' ,
],
]);
The storefront_settings field is cast as an array (app/Models/Shop.php:30) and can store any JSON-serializable configuration data.
Storefront Routes
All storefront routes are prefixed with /store/{shop:slug} and use route binding to load the shop by its slug:
Available Storefront Routes
// routes/storefront.php:20-26
Route :: get ( '/' , [ StorefrontController :: class , 'index' ]) -> name ( 'storefront.index' );
Route :: get ( '/products' , [ StorefrontController :: class , 'products' ]) -> name ( 'storefront.products' );
Route :: get ( '/products/{product:slug}' , [ StorefrontController :: class , 'show' ]) -> name ( 'storefront.product' );
Route :: get ( '/services' , [ StorefrontController :: class , 'services' ]) -> name ( 'storefront.services' );
Route :: get ( '/services/{service:slug}' , [ StorefrontController :: class , 'showService' ]) -> name ( 'storefront.service' );
Example URLs:
Homepage: /store/downtown-store
Product listing: /store/downtown-store/products
Product detail: /store/downtown-store/products/wireless-headphones
Storefront Middleware
All storefront routes are protected by the storefront.enabled middleware, which verifies that the shop has e-commerce enabled:
// routes/storefront.php:20
Route :: prefix ( 'store/{shop:slug}' )
-> middleware ( 'storefront.enabled' )
-> name ( 'storefront.' )
-> group ( function () {
// routes...
});
If a shop has storefront_enabled set to false, customers will receive a 403 error when trying to access the storefront.
Storefront Settings Schema
The storefront_settings field supports the following configuration options:
Primary color for the storefront theme (hex format)
URL to the shop’s logo image
URL to the homepage banner image
Markdown-supported text describing the shop
Customer support email address
Customer support phone number
Shipping terms and conditions
Return and refund policy details
{
"enabled" : true ,
"message" : "Free shipping on orders over $50!" ,
"background_color" : "#10b981" ,
"text_color" : "#ffffff"
}
{
"facebook" : "https://facebook.com/yourshop" ,
"instagram" : "https://instagram.com/yourshop" ,
"twitter" : "https://twitter.com/yourshop"
}
Currency and Tax Settings
Storefronts inherit currency and tax configuration from the parent shop:
// app/Models/Shop.php:24-26
$shop -> currency ; // e.g., 'USD'
$shop -> currency_symbol ; // e.g., '$'
$shop -> currency_decimals ; // e.g., 2
$shop -> vat_enabled ; // boolean
$shop -> vat_rate ; // decimal (e.g., 7.5 for 7.5%)
$shop -> vat_inclusive ; // boolean - whether prices include VAT
All product prices displayed on the storefront will automatically format using the shop’s currency settings.
Customer Journey
A typical customer workflow on the storefront:
Browse Products - Customer visits /store/{shop}/products and browses available items
Add to Cart - Items are added to session-based or customer-linked cart (routes/storefront.php:27-31)
Create Account - Guest registers or logs in at /store/{shop}/register or /store/{shop}/login
Checkout - Customer proceeds to checkout at /store/{shop}/checkout (auth required)
Payment - Complete payment via available methods (Paystack, Cash on Delivery, Bank Transfer)
Confirmation - Order confirmation displayed at /store/{shop}/checkout/success/{order}
Multi-Tenant Isolation
Storefronts are fully tenant-isolated:
// app/Models/Shop.php:15-17
use BelongsToTenant ;
// Every shop query must filter by tenant_id
$shop = Shop :: query ()
-> where ( 'tenant_id' , $tenant -> id )
-> where ( 'storefront_enabled' , true )
-> where ( 'slug' , $slug )
-> first ();
Always ensure tenant isolation when querying shops or storefront data. Never expose one tenant’s storefront to another tenant’s customers.
Example: Updating Storefront Settings
use App\Models\ Shop ;
$shop = Shop :: query () -> find ( $shopId );
$shop -> update ([
'storefront_enabled' => true ,
'storefront_settings' => [
'theme_color' => '#6366f1' ,
'logo_url' => asset ( 'storage/logos/shop-logo.png' ),
'banner_url' => asset ( 'storage/banners/hero-banner.jpg' ),
'about_text' => 'We offer premium electronics and gadgets.' ,
'contact_email' => '[email protected] ' ,
'contact_phone' => '+234 800 123 4567' ,
'shipping_policy' => 'Free shipping on orders over ₦10,000.' ,
'return_policy' => '14-day return policy for unopened items.' ,
'announcement_bar' => [
'enabled' => true ,
'message' => 'New Year Sale - 20% off everything!' ,
'background_color' => '#dc2626' ,
'text_color' => '#ffffff' ,
],
'social_links' => [
'instagram' => 'https://instagram.com/myshop' ,
'facebook' => 'https://facebook.com/myshop' ,
],
],
]);