This guide will get your e-commerce site up and running quickly.
- Node.js 20+ installed
- Agility CMS account
- Stripe account (test mode)
- Code already deployed to this repo
- Go to https://dashboard.stripe.com/test/apikeys
- Copy your Publishable key (starts with
pk_test_) - Copy your Secret key (starts with
sk_test_)
Open .env.local and update these lines:
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_your_key_here
STRIPE_SECRET_KEY=sk_test_your_key_hereOpen a new terminal and run:
# Install Stripe CLI if you haven't
brew install stripe/stripe-cli/stripe
# Login to Stripe
stripe login
# Forward webhooks to local server
stripe listen --forward-to localhost:3000/api/webhooks/stripeCopy the webhook secret (starts with whsec_) and add to .env.local:
STRIPE_WEBHOOK_SECRET=whsec_your_secret_herenpm install
npm run devVisit: http://localhost:3000
Category Model:
- Go to Agility CMS → Settings → Models → Content Models
- Click "New Model"
- Name:
Category, Reference:categories - Add field:
Title(Text, Required) - Save
Size Model:
- Create new model
- Name:
Size, Reference:sizes - Add fields:
Title(Text, Required)Code(Text, Required)Description(Text)
- Save
Product Model:
- Create new model
- Name:
Product, Reference:products - Add fields:
Title(Text, Required)SKU(Text, Required)Slug(Text, Required)Description(HTML)Category(Linked Content → Category)Base Price(Number, Required)Featured Image(Image, Required)Variants(Nested Content List - create ProductVariant schema)
- Save
ProductVariant Schema (nested): When adding Variants field, create new schema with fields:
Details(Text)Variant SKU(Text, Required)Color(Text, Required)Color HEX(Text, Required) - e.g., "#000080"Size(Linked Content → Size)Price(Number, Required)Variant Image(Image, Required)Stock Quantity(Number, Required)Length MM(Number)Width MM(Number)Height MM(Number)Weight Grams(Number)
Go to Content → Sizes → New:
- Small: Title: "Small", Code: "S"
- Medium: Title: "Medium", Code: "M"
- Large: Title: "Large", Code: "L"
Go to Content → Categories → New:
- Apparel: Title: "Apparel"
Go to Content → Products → New:
Basic Info:
- Title: "Test T-Shirt"
- SKU: "TSHIRT-001"
- Slug: "test-tshirt"
- Description: "A test product"
- Category: Apparel
- Base Price: 24.99
- Featured Image: Upload any image
Add Variant (click Add Variant):
- Details: "Navy Blue, Medium"
- Variant SKU: "TSHIRT-001-NAVY-M"
- Color: "Navy Blue"
- Color HEX: "#000080"
- Size: Medium
- Price: 24.99
- Variant Image: Upload image
- Stock Quantity: 10
Save and Publish!
- View Products: http://localhost:3000/products
- Click on Test T-Shirt
- Add to Cart
- Click Cart Icon (top right)
- Checkout
- Use Test Card: 4242 4242 4242 4242
- Expiry: Any future date
- CVC: Any 3 digits
- ZIP: Any 5 digits
- Complete Payment
- See Success Page
Your e-commerce site is now running with:
- ✅ Product catalog
- ✅ Shopping cart
- ✅ Stripe checkout
- ✅ Order confirmation
Create more products following the same pattern as Step 4.
Edit Tailwind classes in components:
src/components/products/ProductCard.tsxsrc/app/products/page.tsxsrc/components/cart/CartDrawer.tsx
-
Push to GitHub:
git add . git commit -m "Add e-commerce functionality" git push
-
Deploy to Vercel:
# Or connect GitHub repo in Vercel dashboard vercel --prod -
Update environment variables in Vercel:
- Add all values from
.env.local
- Add all values from
-
Set up production webhook in Stripe Dashboard:
- Endpoint:
https://yourdomain.com/api/webhooks/stripe - Events:
checkout.session.completed - Copy signing secret to Vercel env vars
- Endpoint:
Products not showing?
- Check products are published in Agility CMS
- Check console for errors:
npm run devoutput - Verify
AGILITY_API_FETCH_KEYin.env.local
Cart not working?
- Clear browser localStorage
- Check browser console for JavaScript errors
- Refresh page
Stripe errors?
- Verify API keys are correct (test mode keys start with
pk_test_andsk_test_) - Make sure webhook is running:
stripe listen --forward-to localhost:3000/api/webhooks/stripe - Check Stripe Dashboard for errors
Images not loading?
- Verify images are uploaded in Agility CMS
- Check browser Network tab for 404 errors
- Clear Next.js cache:
rm -rf .next && npm run dev
- Check ECOMMERCE_README.md for detailed docs
- Check AGILITY_SETUP_GUIDE.md for CMS setup
- Check IMPLEMENTATION_SUMMARY.md for overview
- Check browser console for errors
- Check Stripe Dashboard for payment issues
Stripe provides test cards for different scenarios:
- Success: 4242 4242 4242 4242
- Requires Authentication: 4000 0025 0000 3155
- Declined: 4000 0000 0000 9995
- Insufficient Funds: 4000 0000 0000 9995
More test cards: https://stripe.com/docs/testing
Want to add the full swag shop? See AGILITY_SETUP_GUIDE.md Step 9 for complete product templates:
- Classic Logo T-Shirt (3 variants)
- Embroidered Baseball Cap (2 variants)
- Premium Zip Hoodie (3 variants)
- Comfort Crew Socks (2 variants)
That's it! You now have a fully functional e-commerce site. 🎉