Koovira Dev Docs
20-modules/ecommerce/overview.md

Module: CommerceX / E-commerce (ecommerce / merchant)

Status: 🟒 Production verified (real orders + commission recorded) · Last validated: 2026-09-06 · Priority: P0 (Critical)

This is the reference/exemplar module β€” it demonstrates the full documentation depth every other module page should reach. It is validated against classs/CommerceOrdersModule.php, classs/ProductsModule.php, api/commerce/*, and the live schema.

Key-mapping note: this module is ecommerce in kv_module_control but merchants enroll under the merchant key in kv_module_registry. See ../../00-architecture/module-registry.md.


A. Purpose

Online marketplace: merchants list products; customers buy and pay (wallet-first, optional COD); Koovira routes fulfilment, takes commission, and settles the merchant. Revenue = 5% platform commission per order (platform_commission_settings), plus delivery/fees.

Ground-truth scale (2026-09-06): products_master = 24,761 products; orders_master = 13 orders; commission_transactions = 92 (cross-module); platform_commission_settings = 11 rules. Live commission has been processed for CommerceX (systemflow audit cited 15 processed txns β‰ˆ β‚Ή1,034) β€” verify current values before quoting.

B. Actors

  • Customer / buyer β€” browses, carts, checks out, tracks, returns/reviews. (buyer_id)
  • Merchant / seller β€” lists products, manages inventory, accepts & fulfils orders, settles.

(seller_id, company_id)

  • Merchant staff β€” sub-user with scoped permissions (see ../../10-actors/README.md).
  • Delivery/courier/hyperlocal partner β€” fulfilment (routing engine).
  • Admin β€” commission config, disputes, refunds (padmin).

C. Entry points

Consumer: /ecomproductlist.php, /commercex.php, product detail pages, /mycart.php (checkout), /commerce_order_view_page (order view; assets/newjs/commerce_order_view_page.js). AJAX: api/commerce/cart.php (cart + checkout), api/v1/. Merchant: /merchant/ecommerce_products.php, _product_add/edit, ecommerce_inventory.php, orders.php, vieworder.php. External API: api/developer/products.php, api/developer/orders.php (token-scoped products. / orders.*).

D. Onboarding / preconditions

  • Module ecommerce active in kv_module_control (it is: master_status=1).
  • Merchant enrolled (merchant type), company created (company_master), module setup done.
  • Selling gated by KYC/verification and membership per platform rules (validate the exact gate in

the merchant product-publish path when documenting section E publish feature).

  • Buying requires only a logged-in customer_master user with wallet balance (wallet-first) or an

allowed COD path.

E. Feature registry (prefix COM-)

Seeded here; maintain the master list in ../../STATUS.md.

IDFeatureActorGateEntryTables (write)CodeMoneyStatus
COM-001Browse / product listanon+customermodule onecomproductlist.phpβ€”ProductsModulenone🟒
COM-002Product detail (buyer view)anon+customerpublished + seller activeproduct pageβ€”ProductsModule::getProductDetailForBuyer()none🟒
COM-003Add to cartcustomerloginmycart.php / api/commerce/cart.phpshopping_cart, cart_items(0)api/commerce/cart.phpnone🟑 (see data-model: cart storage)
COM-004Checkout with walletcustomerlogin + balanceapi/commerce/cart.phporders_master, order_status_history, kv_order_finance_*, wallet_transactions, commission_transactionsCommerceOrdersModule::checkoutWithWallet() :563wallet debit + commission🟒
COM-005Checkout CODcustomerallow_cod=1sameorders_master (payment_method='cod')checkoutWithWallet() :597-609deferred🟑 (gated by admin flag)
COM-006Quick vs regular deliverycustomerquick needs lat/lng + eligible sellercheckoutorders_master.delivery_mode, commerce_order_routingCommerceRoutingEnginedelivery fee🟑 (0 sellers opted into quick)
COM-007Vendor acceptance / routingsellervendor-acceptance enabledcheckoutβ†’acceptcommerce_order_routing (8), order_status_historyCommerceRoutingEngine::getFulfillmentCandidates()β€”πŸŸ’
COM-008Delivery evidence + OTP + unboxingbuyer/courierorder dispatcheddelivery linksorder_delivery_*, order_unboxing_videos, order_parcel_custodyCommerceOrdersModule delivery-trust methods :203-393β€”πŸŸ’
COM-009Cancel / return / refundbuyer/seller/adminstatus + windoworder view / padminorders_master (cancel/return/refund cols), kv_order_finance_entries(refund path)refund🟠 (validate refund writer)
COM-010Merchant product create/publishseller/staffKYC + membership + modulemerchant/ecommerce_product_add.phpproducts_master, product_variants, seller_inventoryProductsModuleβ€”πŸŸ’
Rows above are validated where a code citation is given; those marked 🟠/🟑 name exactly what still needs confirmation. Fill the remaining flows into their own files under this folder.

Detailed pages

Cross-module dependencies

CommerceX β†’ Wallet (debit) β†’ central finance ledger β†’ Commission β†’ Billing/Invoice β†’ Notifications, and β†’ Routing/Delivery (hyperlocal/courier) for fulfilment. A product's availability depends on the merchant's active/verified state (getProductDetailForBuyer(publicOnly=true)).

Change-impact (if you change checkout)

Touches money (wallet, finance ledger, commission), inventory (seller_inventory/ products_master.stock_quantity), routing, delivery-trust, and notifications. Re-test: wallet balance correctness, commission recorded once, finance-ledger keyed to the right module, the two money-integrity guards below still hold.

Money-integrity guards already in place (do not regress)

Both are in checkoutWithWallet() and were real production bugs:

  • Server-side pricing only (:692-748): variant/price come from product_variants / DB, never

from the client. A client items[0][variant_json]={"price":1} previously bought anything for β‚Ή1.

  • publicOnly availability guard (:667-683): a product unpublished/paused, or whose company

was suspended after it was carted, cannot convert to a paid order.