Commerce rules ensure developers understand the proper workflow for creating, deploying, and maintaining Commerce storefronts. These rules prevent common mistakes and enforce best practices specific to Commerce development.
## Critical Concepts
### Store vs Storefront
The most important concept in Commerce development is understanding the distinction:
| Aspect | Commerce Store | Storefront (LWR Site) |
- [ ] Test in Experience Builder before committing
- [ ] Document Store configuration steps
**Before deployment:**
- [ ] Verify target org has Commerce licenses
- [ ] Create Store in target org with matching name
- [ ] Deploy Experience metadata only
- [ ] Configure payment/tax/shipping in target
- [ ] Test buy flow end-to-end
## Integration with Other Rules
Commerce rules work together with:
### LWC Development Guardrails
**`rules/lwc-development/lwc-requirements.md`**
When creating custom Commerce components:
- Apply LDS-first approach (no Apex unless necessary)
- Use `lightning-` base components
- Expose `@api` properties for Experience Builder
- Follow SLDS design patterns
- Use `NavigationMixin` for routing
### Spec-Driven App Development Standards
**`rules/spec-driven-dev/app-dev.md`**
When building complete Commerce solutions:
- Document store configuration requirements
- Create permission sets for Commerce users
- Follow naming conventions
- Maintain architecture documentation
## Common Questions
### Q: Can I create a Commerce storefront entirely in source control?
**A:** No. You must create the Commerce Store in the org first (via UI or API), which auto-generates the storefront. You can then retrieve and customize that storefront metadata.
### Q: What if I want to automate Store creation?
**A:** Use Commerce APIs to create WebStore records programmatically. Then retrieve the generated Experience metadata. Still don't create storefront JSON manually.
### Q: How do I migrate a Store to production?
**A:**
1. Create Store in production org (via UI or API) with same name
2. Export/import Store data (WebStore, BuyerGroup, EntitlementPolicy records)
3. Deploy Experience metadata from source control
4. Configure payment/tax/shipping in production
5. Test thoroughly before going live
### Q: Can I have multiple Stores in one org?
**A:** Yes. Each Store gets its own WebStore record and associated Experience site. Retrieve each storefront separately and organize in different directories.