Order Flow
Flow Overview
Process Description
-
Cart Creation
- Customer adds products (courses, bundles, or course videos) to cart
- Cart model stores:
- Product information and customer details
- Affiliate code (ref) for tracking affiliate sales
- Promo code for promotion tracking
-
Order Creation
- When customer attempts payment, an order is created
- Order contains items through OrderItem pivot table
- Order tracks payment status, method, and total amounts
- Order items store product-specific details (prices, discounts, etc.)
-
Payment Processing
- Order status is updated based on payment result
- Upon successful payment, order is marked as completed
-
Subscription Creation & Update
- Two jobs are triggered after successful payment:
- ProcessOrderVideos: Handles video-specific payments and adds them to the relevant subscription
- ProcessOrderSubscriptions: Creates or updates (renews) subscriptions for each course (even those in bundles)
- Customer gains access to purchased content through these subscriptions
- Two jobs are triggered after successful payment:
Post-Purchase Processing
-
Affiliate Tracking
- System identifies affiliate through ref code in cart
- Updates affiliate sales records and commission calculations
-
Promotion Tracking
- Records promotion usage through promo_code
- Updates promotion statistics for campaign analysis
-
Loyalty Points Calculation
- Calculates points based on order total
- Creates points record for customer
- Updates customer's total points balance
Key Models
- Cart: Temporary storage for products, affiliate codes, and promo codes before purchase
- Order: Tracks the complete purchase transaction
- OrderItem: Pivot table connecting orders with purchased products
- Subscription: Manages access to purchased content
- Point: Defines point types and rules for loyalty program
- PointsRecord: Tracks customer loyalty points transactions
- Promotion: Manages promotional campaigns and tracking
- Customer: Includes affiliate marketers who can refer sales