Core Concepts
Function
What is a Function?
Functions is the secret sauce of Ollie Shop. Is where the magic happens.
All Functions run server-side guaranteeing security and maximum performance.
Use functions to run the business logic of the customization. Make requests to external systems, transform payloads, go crazy.
Event-Driven Architecture
Functions operate on an event-driven model. Each function listens for specific events and executes when triggered:
Available Events
Event | Trigger | Use Cases |
---|---|---|
items | Cart items added/updated | Inventory validation, pricing rules, upsells |
cart | Cart data requested | Dynamic pricing, tax calculations |
customer | Customer info updated | Profile validation, loyalty program integration |
shipping | Shipping method selected | Rate calculations, delivery date estimation |
delivery | Delivery details updated | Address validation, delivery scheduling |
payment | Payment method chosen | Payment processor integration, fraud detection |
extension | Custom extensions updated | Third-party service integration |
Execution Timing
Configure when your function runs:
- Before: Execute before sending data to your e-commerce platform
- Example: Validate cart quantity limits before adding items
- After: Execute after the platform processes the request
- Example: Hide payment methods based on new cart total
Error Handling
Configure how your function responds to errors:
- Throw: Abort the operation and return a 4xx error to the user
- Skip: Continue processing without raising errors
Use the Ollie SDK’s Reject
function to return structured error responses:
Function Requirements
Functions follow the same structure as Components:
Required Files
- TypeScript file - Your function logic
- package.json - Dependencies and metadata
- node_modules/ - Installed dependencies
Functions don’t require CSS files since they run server-side
Basic Function Structure
Deployment
Deploy functions using the Ollie Builder API:
- Compress your function folder as a ZIP file
- Use the API with your function ID
- Associate with the appropriate Version
Development Guide
Learn how to build and deploy Functions step-by-step