Promotions & Offers¶
Source: Various widget and provider files across the Flutter app.
Overview¶
The promotions system allows admins to create campaign timelines and sellers to submit discount offers on specific products. The mobile app displays these offers as discounted pricing on product cards and detail pages.
Data Flow¶
sequenceDiagram
participant A as Admin (Web)
participant S as Seller (Web)
participant DB as Supabase
participant M as Mobile App
A->>DB: Create promotion (draft → active)
S->>DB: Create offer (product + discount)
DB-->>DB: Offer computed with offerPrice
M->>DB: Fetch active promotions
M->>DB: Fetch active offers
DB-->>M: Promotion + Offer data
M->>M: Build activeOffersMap (productId → offer)
M->>M: Display offer pricing with strikethrough
APIs¶
Source: pharmanet/lib/core/api/promotion_api.dart
| Method | Description |
|---|---|
fetchActivePromotions() |
Current active promotions |
getPromotionById(id) |
Single promotion detail |
getPromotionBanners(promotionId) |
Banners for a promotion |
Source: pharmanet/lib/core/api/offer_api.dart
| Method | Description |
|---|---|
fetchActiveOffers() |
All active offer products |
getOffersByPromotion(promotionId) |
Offers for a specific promotion |
getOffersByProduct(productId) |
Offers for a specific product |
Providers¶
Source: pharmanet/lib/core/providers/promotion_provider.dart
| Provider | Type | Description |
|---|---|---|
activePromotionsProvider |
FutureProvider<List<Promotion>> |
Active promotions for Hot Deals carousel |
promotionDetailsProvider |
FutureProvider.family<String> |
Single promotion detail |
activeOffersProvider |
FutureProvider<List<OfferProduct>> |
All active offer products |
activeOffersMapProvider |
Provider<Map<String, OfferProduct>> |
productId → best offer (computed) |
offersByPromotionProvider |
FutureProvider.family<String> |
Offers for a promotion |
offersByProductProvider |
FutureProvider.family<String> |
Offers for a product |
Offer Price Calculation¶
// In offer creation (CreateOffer.jsx):
if (discountType === 'percentage') {
offerPrice = originalPrice - (originalPrice * discountValue / 100);
} else {
offerPrice = originalPrice - discountValue;
}
UI Integration Points¶
| Location | Component | File |
|---|---|---|
| Home screen | Hot Deals carousel | features/public/presentation/pages/home_tab.dart |
| Product card | Striketrhough pricing | widgets/shared/product_card.dart |
| Product detail | Discount badge + offer price | features/pharmacy/presentation/widgets/product_header_info.dart |
| Product detail | Offer banner section | features/pharmacy/presentation/pages/product_details_page.dart |
Related¶
- Products — Offer pricing on product display
- Home — Hot Deals carousel
- Admin: Promotions — Promotion management
- Seller: Offers — Offer creation