Pillar 5. E-Commerce, Pricing, Loyalty, CRM & Event Marketing
Multi-Tier Loyalty Points, Voucher Stacking, Dynamic Bundle Pricing, B2B Credit Limits, and Headless Order State Machines.
Pillar 5. E-Commerce, Pricing, Loyalty, CRM & Event Marketing
6 Domain Combo Suites (20+ Isolated Slices)
Promotional voucher stacking rules, B2B credit aging terms, dynamic combo pricing, headless order state machines, and lead routing.
📦 Package Catalog
| Package Name | Path | Architecture Paradigm & Key Exports |
|---|---|---|
@kido/discount-loyalty | packages/discount-loyalty | Loyalty Points, Voucher Stacking & Promotional Rules: • VoucherEngine, LoyaltyCalculator, evaluateStackingRules, calculateTierProgress |
@kido/bundle-pricing | packages/bundle-pricing | Dynamic Combo Pricing, BOGO & Prorated Split Allocation: • BundlePricingEngine, calculateVolumeTierPrice, allocateBundleDiscountProRata |
@kido/b2b-credit | packages/b2b-credit | B2B Credit Limits, Net-30/60/90 Aging Buckets & Dunning Guard: • B2BCreditEngine, calculateAgingBuckets, evaluateCreditOrderRelease |
@kido/ecommerce-admin | packages/ecommerce-admin | Headless Order State Machine, SKU Variant Matrix & RMA Engine: • OrderStateMachine, generateSkuMatrix, RmaRefundCalculator |
@kido/lead-crm | packages/lead-crm | Lead Scoring, Weighted Round-Robin Assignment & SLA Tracker: • LeadScoringEngine, WeightedRoundRobinAssigner, SlaBreachDetector |
@kido/event-marketing | packages/event-marketing | Event Ticketing QR Signer, Check-in Scanner & Viral Waitlist: • TicketQrSigner, verifyTicketCheckin, WaitlistPromoter |
🔍 Key Architectural Patterns
1. Safe Voucher Stacking & Anti-Abuse
Evaluate complex promotional rules (e.g. 10% store discount + free shipping voucher + loyalty point redemption) without accidentally creating negative order totals or violating merchant margins:
import { evaluateStackingRules } from '@kido/discount-loyalty';
const result = evaluateStackingRules({
cartSubtotal: 1200000,
vouchers: [
{ code: 'SPRING10', type: 'PERCENTAGE', value: 10, categoryExclusions: [] },
{ code: 'FREESHIP', type: 'FIXED_SHIPPING', value: 35000 },
],
maxStackedDiscounts: 2,
});2. Prorated Bundle Discount Allocation
When selling a 3-item bundle at a discount, accounting systems need the exact prorated discount allocated to each SKU so that partial returns (RMA) calculate refunds accurately:
import { allocateBundleDiscountProRata } from '@kido/bundle-pricing';
const allocatedItems = allocateBundleDiscountProRata({
bundlePrice: 800000,
items: [
{ sku: 'SHIRT', regularPrice: 400000 },
{ sku: 'PANTS', regularPrice: 500000 },
{ sku: 'BELT', regularPrice: 100000 },
],
});
// Each item receives an exact pro-rata proportion of the 200,000 VND discount3. B2B Credit Net-30 Aging & Order Hold Guard
Evaluate whether wholesale corporate clients are eligible for new credit-based deliveries based on overdue aging buckets:
import { B2BCreditEngine } from '@kido/b2b-credit';
const engine = new B2BCreditEngine();
const decision = engine.evaluateCreditOrderRelease({
creditLimit: 500000000,
currentOutstanding: 320000000,
newOrderAmount: 80000000,
agingDays: 24, // Within Net-30
});
// decision.approved === true