From Game in the Brain Wiki
Repo:comfac-webshop/EntryPoints — Application Entry Points
How This App Starts
Installation & Startup
Frappe Webshop is a standard Frappe app that hooks into the framework:
- Bench loads the app via
webshop/__init__.py
- Hooks (
webshop/hooks.py) register with Frappe
- Website routes are registered for storefront pages
- DocTypes are synced to database
Key Commands
| Command |
Purpose
|
bench --site [site] install-app webshop |
Install webshop on a site
|
bench --site [site] migrate |
Sync DocTypes, run patches
|
bench build |
Compile SCSS to CSS
|
bench start |
Start development server
|
Main Config Files
hooks.py
Location: webshop/hooks.py
Key configurations:
| Config Section |
What It Controls
|
required_apps |
Dependencies: payments, erpnext
|
web_include_js/css |
Assets loaded on every web page
|
website_generators |
Auto-created pages (Website Item, Item Group)
|
override_doctype_class |
Python class overrides for Item, Item Group, Payment Request
|
doc_events |
Sync Item changes to Website Item
|
on_session_creation |
Initialize cart when user logs in
|
update_website_context |
Add cart data to all template contexts
|
Webshop Settings (DocType)
Location: Frappe Desk → Webshop Settings
Critical settings configured via UI:
| Setting |
Purpose
|
| Enabled |
Turn store on/off
|
| Price List |
Which ERPNext Price List to use
|
| Default Shopping Cart Company |
Company for quotations
|
| Default Currency |
Currency for display
|
| Enable Wishlist |
Feature toggle
|
| Show Stock Availability |
Display stock levels
|
| Redirect to Checkout on Add to Cart |
Behavior setting
|
Environment Variables
Standard Frappe environment variables apply:
| Variable |
Purpose
|
FRAPPE_BENCH_ROOT |
Bench installation path
|
Webshop-specific context is set in update_website_context hook.
How to Verify It's Running Correctly
Health Checks
- Webshop Settings: Frappe Desk → Webshop Settings → Verify "Enabled" is checked
- Price List: Verify a Price List is selected and has items
- Website Items: Create/publish at least one Website Item
- Storefront: Visit
/all-products — should see product listing
- Item Page: Click a product — should see detail page
- Cart: Add item to cart — cart count should update
Log Locations
| Log Type |
Location
|
| Frappe web logs |
logs/web.log or docker logs
|
| Browser console |
F12 → Console (JavaScript errors)
|
Common Issues
| Symptom |
Likely Cause |
Fix
|
| /all-products 404 |
Website generator not synced |
Run bench migrate
|
No products showing |
No published Website Items |
Create Website Items
|
Cart not working |
Missing Price List |
Configure Webshop Settings
|
Styles missing |
Assets not built |
Run bench build
|
Images not loading |
File permissions |
Check sites/[site]/public/files/
|
Request/Task Flow
Example: Adding Item to Cart
- User Action: Clicks "Add to Cart" on product page
- Client-Side: JavaScript calls
webshop.webshop.shopping_cart.cart.add_to_cart
- API Handler:
cart.py::add_to_cart() whitelisted function
- Quotation Creation: Gets or creates cart Quotation for user
- Quotation Item: Adds Item to Quotation.items child table
- Save: Saves Quotation (draft state)
- Cookie Update: Updates cart_count cookie
- Response: Returns updated cart info
- UI Update: Cart icon shows updated count
Example: Product Page Display
- URL Request:
/item/[website-item-name]
- Route Resolution: Frappe matches
website_generators pattern
- Permission Check:
has_website_permission hook validates access
- Context Building:
WebsiteItem.get_context() prepares data
- Template Rendering:
templates/webshop/website_item.html rendered
- Response: Full HTML page with product details
Example: Checkout Process
- Cart Review: User reviews cart at
/cart
- Address Selection: User selects/changes shipping/billing address
- Shipping Rule: Available shipping options calculated
- Place Order: Cart Quotation converted to Sales Order
- Payment: Payment Request created, redirected to payment gateway
- Confirmation: On payment success, order confirmed
- Email: Order confirmation email sent
Integration Points
ERPNext Integration
| ERPNext DocType |
Webshop Usage
|
| Item |
Source for Website Item
|
| Item Group |
Product categories
|
| Quotation |
Shopping cart storage
|
| Sales Order |
Final order creation
|
| Price List |
Product pricing
|
| Address |
Customer shipping/billing
|
| Customer |
Registered shoppers
|
Website Routes
| Route |
Handler
|
/all-products |
Product listing with filters
|
/item/<name> |
Individual product page (website generator)
|
/cart |
Shopping cart
|
/checkout |
Checkout flow
|
/orders |
Order history
|
/wishlist |
Saved items
|
API Endpoints (Whitelisted)
| Endpoint |
Purpose
|
get_cart_quotation |
Get current cart data
|
add_to_cart |
Add item to cart
|
update_cart |
Update quantities
|
place_order |
Convert cart to order
|
get_product_info |
Get item availability/pricing
|
Related Pages