ServiceShopping Cart Config
Service

Shopping Cart Config

Configure service-level shopping cart behavior including pricing, promotions, loyalty, logistics, Redis caching, and checkout mapping to orders.

ShoppingCartConfig

MPO Version: 1.3.0

Shopping cart configuration chapter. When enabled, auto-generates Cart, CartItem, and optionally Campaign/Coupon DataObjects with Redis-first architecture for hyper-scalable cart management.

interface ShoppingCartConfig = {
  basicSettings : ShoppingCartBasicSettings;
  pricingSettings : ShoppingCartPricingSettings;
  itemSettings : ShoppingCartItemSettings;
  productCatalogSettings : ShoppingCartProductCatalogSettings;
  logisticsSettings : ShoppingCartLogisticsSettings;
  loyaltySettings : ShoppingCartLoyaltySettings;
  promotionSettings : ShoppingCartPromotionSettings;
  redisSettings : ShoppingCartRedisSettings;
  eventSettings : ShoppingCartEventSettings;
  apiSettings : ShoppingCartApiSettings;
  checkoutSettings : ShoppingCartCheckoutSettings;
}
FieldDescription
basicSettingsCore cart settings including activation, naming, currency, and guest cart support. The useShoppingCartFeature flag activates the entire shopping cart functionality.
pricingSettingsPrice calculation settings including VAT handling, rounding, discounts, shipment, and extra charges.
itemSettingsCart item configuration including what item properties to generate.
productCatalogSettingsOptional product catalog integration for automatic item population when adding products.
logisticsSettingsShipping logistics settings for weight, dimensions, and volume tracking.
loyaltySettingsLoyalty program settings for points earning and redemption.
promotionSettingsPromotion engine configuration including static and dynamic promotions.
redisSettingsRedis caching configuration for hyper-scalable cart management.
eventSettingsEvent hooks for custom business logic injection.
apiSettingsGenerated API routes configuration.
checkoutSettingsCheckout settings for cart-to-order conversion. Configures how checkout creates orders, property mappings, and event publishing.

ShoppingCartBasicSettings

MPO Version: 1.3.0

Core shopping cart settings with activation flag. When useShoppingCartFeature is true, the Cart and CartItem DataObjects are auto-generated.

interface ShoppingCartBasicSettings = {
  useShoppingCartFeature : Boolean;
  cartObjectName : String;
  currency : String;
  supportGuestCart : Boolean;
  supportNotes : Boolean;
  supportMetadata : Boolean;
  churningPeriodDays : Integer;
  abandonmentPeriodDays : Integer;
}
FieldDescription
useShoppingCartFeatureEnables shopping cart functionality for this service. When true, auto-generates Cart and CartItem DataObjects with all pricing, status, and calculation properties.
cartObjectNameName for the auto-generated Cart DataObject (e.g., 'cart', 'shoppingCart'). Related objects are named based on this: {name}Item, {name}Campaign, etc.
currencyThe currency code for this cart (e.g., USD, EUR, TRY). All monetary calculations use this currency.
supportGuestCartWhether to support anonymous/guest carts before user login. Adds sessionId property for session binding.
supportNotesWhether to include a notes field for customer special instructions.
supportMetadataWhether to include a metadata JSON field for custom extensibility.
churningPeriodDaysNumber of days of inactivity before a cart is marked as 'churning'. Churning carts may trigger reminder emails. Set to 0 to disable churning detection.
abandonmentPeriodDaysNumber of days of inactivity before a cart is marked as 'abandoned'. Abandoned carts may be deleted or archived. Must be greater than churningPeriodDays.

ShoppingCartPricingSettings

MPO Version: 1.3.0

Price calculation settings. Controls VAT handling, rounding, and which charge types are supported.

interface ShoppingCartPricingSettings = {
  catalogPricesIncludeVat : Boolean;
  defaultVatRate : Double;
  roundingStrategy : RoundingStrategy;
  roundingPrecision : Integer;
  discountSettings : CartDiscountConfig;
  shipmentSettings : CartShipmentConfig;
  extraChargeSettings : CartExtraChargeConfig;
}
FieldDescription
catalogPricesIncludeVatWhether product prices include VAT. If true, prices are normalized to ex-VAT internally for correct tax calculation.
defaultVatRateDefault VAT rate as decimal (e.g., 0.18 for 18%) when item doesn't specify its own rate.
roundingStrategyWhen to round monetary values: perLine (recommended), perItem, or atTotal.
roundingPrecisionDecimal places for rounding (typically 2).
discountSettingsDiscount calculation configuration.
shipmentSettingsShipment charge configuration.
extraChargeSettingsExtra charges configuration (handling, packaging, etc.).

RoundingStrategy

Defines when monetary rounding is applied during price calculations.

const RoundingStrategy = {
  perLine: "perLine",
  perItem: "perItem",
  atTotal: "atTotal",
};
EnumDescription
perLineRound each line total after calculating (quantity × unit price). Recommended for most cases.
perItemRound each item's unit price before multiplication. May cause small discrepancies in line totals.
atTotalOnly round the final grand total. Keeps maximum precision but may show odd line totals.

CartDiscountConfig

MPO Version: 1.3.0

Configuration for discount handling.

interface CartDiscountConfig = {
  supportType : DiscountSupportType;
  allocationMode : DiscountAllocationMode;
}
FieldDescription
supportTypeWhat level of discounts are supported: none, cartLevel, itemLevel, or bothLevels.
allocationModeHow cart-level discounts are allocated to items: proportional, byQuantity, lastItem, or customRule.

DiscountSupportType

Defines what types of discounts the cart supports.

const DiscountSupportType = {
  none: "none",
  cartLevel: "cartLevel",
  itemLevel: "itemLevel",
  bothLevels: "bothLevels",
};
EnumDescription
noneNo discounts supported.
cartLevelOnly cart-level discounts (applied to entire cart, then allocated to items).
itemLevelOnly item-level discounts (applied directly to individual items).
bothLevelsBoth cart-level and item-level discounts supported.

DiscountAllocationMode

Defines how cart-level discounts are allocated to individual items for accounting and tax purposes.

const DiscountAllocationMode = {
  proportional: "proportional",
  byQuantity: "byQuantity",
  lastItem: "lastItem",
  customRule: "customRule",
};
EnumDescription
proportionalAllocate discount proportionally based on each item's contribution to subtotal.
byQuantityAllocate discount equally per item quantity.
lastItemApply entire discount to the last item (simplest, least accurate).
customRuleUse custom allocation logic defined in event handler.

CartShipmentConfig

MPO Version: 1.3.0

Configuration for shipment/delivery charges.

interface CartShipmentConfig = {
  supportShipment : Boolean;
  defaultShipmentVatRate : Double;
}
FieldDescription
supportShipmentWhether the cart supports shipment charges.
defaultShipmentVatRateDefault VAT rate for shipping (may differ from product VAT). Uses defaultVatRate if not specified.

CartExtraChargeConfig

MPO Version: 1.3.0

Configuration for additional charges like handling, packaging, insurance, etc.

interface CartExtraChargeConfig = {
  supportExtraCharges : Boolean;
  storeBreakdown : Boolean;
}
FieldDescription
supportExtraChargesWhether the cart supports extra charges beyond shipment.
storeBreakdownWhether to store breakdown of individual extra charges as JSON array.

ShoppingCartItemSettings

MPO Version: 1.3.0

Configuration for cart line items. The CartItem DataObject is auto-generated based on these settings.

interface ShoppingCartItemSettings = {
  itemObjectSuffix : String;
  supportCategory : Boolean;
  supportBrand : Boolean;
  supportProductGroup : Boolean;
  supportVendor : Boolean;
  supportGiftItems : Boolean;
  supportItemMetadata : Boolean;
}
FieldDescription
itemObjectSuffixSuffix for the auto-generated CartItem DataObject name (default: 'Item'). E.g., 'cart' + 'Item' = 'cartItem'.
supportCategoryWhether items track category for filtering and promotions.
supportBrandWhether items track brand for filtering and promotions.
supportProductGroupWhether items track product group ID for variant grouping in promotions.
supportVendorWhether items track vendor/supplier for marketplace scenarios.
supportGiftItemsWhether items can be marked as promotional gifts.
supportItemMetadataWhether items have a metadata JSON field for custom data.

ShoppingCartProductCatalogSettings

MPO Version: 1.3.0

Optional product catalog integration. When enabled, adding a product by ID/barcode automatically populates item properties from the product catalog.

interface ShoppingCartProductCatalogSettings = {
  useProductCatalog : Boolean;
  productDataObject : DataObjectName;
  lookupField : ProductLookupField;
  productMappings : ProductFieldMappings;
}
FieldDescription
useProductCatalogWhether to integrate with a product DataObject for automatic item population.
productDataObjectThe product catalog DataObject to fetch product details from.
lookupFieldField to use for product lookup: 'id' or 'barcode'.
productMappingsWhich product fields to map to cart items. Configure only if your product uses non-standard property names.

ProductLookupField

Field used to look up products when adding to cart.

const ProductLookupField = {
  id: "id",
  barcode: "barcode",
};
EnumDescription
idLook up by product ID
barcodeLook up by product barcode/SKU

ProductFieldMappings

MPO Version: 1.3.0

Maps product DataObject property names to expected names. Only configure if your product uses non-standard names. All fields are optional - only specify overrides.

interface ProductFieldMappings = {
  barcodeField : String;
  nameField : String;
  imageField : String;
  descriptionField : String;
  categoryField : String;
  brandField : String;
  productGroupField : String;
  priceField : String;
  vatRateField : String;
  discountPercentField : String;
  vendorField : String;
  weightField : String;
  lengthField : String;
  widthField : String;
  heightField : String;
  earnedPointsField : String;
}
FieldDescription
barcodeFieldProduct property for barcode (default: 'barcode').
nameFieldProduct property for name (default: 'name').
imageFieldProduct property for image URL (default: 'image').
descriptionFieldProduct property for description (default: 'description').
categoryFieldProduct property for category (default: 'category').
brandFieldProduct property for brand (default: 'brand').
productGroupFieldProduct property for product group (default: 'productGroup').
priceFieldProduct property for price (default: 'price').
vatRateFieldProduct property for VAT rate (default: 'vatRate').
discountPercentFieldProduct property for discount % (default: 'discountPercent').
vendorFieldProduct property for vendor (default: 'vendor').
weightFieldProduct property for weight (default: 'weight').
lengthFieldProduct property for length (default: 'length').
widthFieldProduct property for width (default: 'width').
heightFieldProduct property for height (default: 'height').
earnedPointsFieldProduct property for earned points (default: 'earnedPoints').

ShoppingCartLogisticsSettings

MPO Version: 1.3.0

Configuration for shipping logistics. When enabled, adds weight/dimension properties to Cart and CartItem.

interface ShoppingCartLogisticsSettings = {
  supportLogistics : Boolean;
  supportDimensions : Boolean;
  supportVolume : Boolean;
  supportDimensionalWeight : Boolean;
  dimFactor : Integer;
}
FieldDescription
supportLogisticsWhether to track logistics data (weight, dimensions, volume) for shipping calculations.
supportDimensionsWhether to track length, width, height in addition to weight.
supportVolumeWhether to auto-calculate and store volume.
supportDimensionalWeightWhether to calculate dimensional weight for shipping carriers.
dimFactorDimensional weight factor (default: 5000 for cm/kg, 139 for in/lb).

ShoppingCartLoyaltySettings

MPO Version: 1.3.0

Loyalty program configuration. When enabled, adds points properties to Cart and CartItem.

interface ShoppingCartLoyaltySettings = {
  supportLoyalty : Boolean;
  supportPointsRedemption : Boolean;
  pointsToMoneyRate : Double;
  pointsAllocationMode : PointsAllocationMode;
}
FieldDescription
supportLoyaltyWhether to enable loyalty points functionality.
supportPointsRedemptionWhether customers can redeem points for discounts.
pointsToMoneyRateHow many points equal 1 currency unit (e.g., 100 points = $1).
pointsAllocationModeHow cart-level bonus points are allocated to items.

PointsAllocationMode

Defines how cart-level bonus points are allocated to individual items.

const PointsAllocationMode = {
  proportional: "proportional",
  lastItem: "lastItem",
  highestPrice: "highestPrice",
  firstMatch: "firstMatch",
};
EnumDescription
proportionalAllocate points proportionally based on item value contribution.
lastItemAssign all bonus points to the last item.
highestPriceAssign all bonus points to the highest-priced item.
firstMatchAssign all bonus points to the first qualifying item.

ShoppingCartPromotionSettings

MPO Version: 1.3.0

Promotion engine configuration with two tiers: static promotions (hardcoded for performance) and dynamic promotions (auto-generated DataObjects with full engine).

interface ShoppingCartPromotionSettings = {
  supportPromotions : Boolean;
  conflictResolution : ConflictResolutionMode;
  maxPromotionsPerCart : Integer;
  staticPromotions : StaticPromotionSettings;
  dynamicPromotions : DynamicPromotionSettings;
}
FieldDescription
supportPromotionsWhether to enable promotion functionality. Adds couponCode and appliedCampaignIds fields to Cart.
conflictResolutionHow to handle conflicts between multiple applicable promotions.
maxPromotionsPerCartMaximum promotions per cart (null = unlimited).
staticPromotionsSimple, always-on promotions hardcoded into CartManager for maximum performance.
dynamicPromotionsComplex promotions with auto-generated Campaign and Coupon DataObjects.

ConflictResolutionMode

Defines how to handle multiple applicable promotions.

const ConflictResolutionMode = {
  bestForCustomer: "bestForCustomer",
  applyAll: "applyAll",
  priorityOrder: "priorityOrder",
  exclusive: "exclusive",
};
EnumDescription
bestForCustomerAutomatically select the promotion(s) that give the customer the highest benefit.
applyAllApply all applicable promotions that are stackable.
priorityOrderApply promotions in priority order until max is reached.
exclusiveOnly apply the highest-priority exclusive promotion.

StaticPromotionSettings

MPO Version: 1.3.0

Simple, always-on promotions hardcoded into CartManager for maximum performance. These require no database lookups and are limited to cart-level conditions.

interface StaticPromotionSettings = {
  freeShippingThreshold : FreeShippingPromotion;
  cartTotalDiscount : CartTotalDiscountPromotion;
  cartQuantityDiscount : CartQuantityDiscountPromotion;
  membershipDiscounts : MembershipDiscountPromotion;
  loyaltyPointsMultiplier : LoyaltyPointsMultiplierPromotion;
}
FieldDescription
freeShippingThresholdFree shipping when cart total exceeds a threshold.
cartTotalDiscountTiered percentage or fixed discount based on cart total.
cartQuantityDiscountTiered discount based on total item quantity.
membershipDiscountsDiscounts based on customer membership level.
loyaltyPointsMultiplierPoints multiplier based on membership level.

FreeShippingPromotion

MPO Version: 1.3.0

Static promotion: Free shipping when cart total exceeds threshold.

interface FreeShippingPromotion = {
  enabled : Boolean;
  minCartTotal : Double;
  customerMessage : String;
}
FieldDescription
enabledWhether this promotion is active.
minCartTotalMinimum cart total (ex-VAT) to qualify for free shipping.
customerMessageMessage to display to customer when promotion applies.

CartTotalDiscountPromotion

MPO Version: 1.3.0

Static promotion: Tiered discount based on cart total.

interface CartTotalDiscountPromotion = {
  enabled : Boolean;
  tiers : CartTotalDiscountTier[];
  maxDiscountAmount : Double;
  stackableWithDynamic : Boolean;
}
FieldDescription
enabledWhether this promotion is active.
tiersArray of discount tiers. Evaluated top-down, first matching tier applies.
maxDiscountAmountOptional cap on the maximum discount amount.
stackableWithDynamicWhether this discount can stack with dynamic promotions.
CartTotalDiscountTier

MPO Version: 1.3.0

A single tier in cart total discount promotion.

interface CartTotalDiscountTier = {
  minCartTotal : Double;
  discountPercent : Double;
  discountAmount : Double;
  customerMessage : String;
}
FieldDescription
minCartTotalMinimum cart total to activate this tier.
discountPercentPercentage discount to apply (e.g., 10 for 10%). Mutually exclusive with discountAmount.
discountAmountFixed discount amount to apply. Mutually exclusive with discountPercent.
customerMessageMessage to display when this tier applies.

CartQuantityDiscountPromotion

MPO Version: 1.3.0

Static promotion: Tiered discount based on total item quantity.

interface CartQuantityDiscountPromotion = {
  enabled : Boolean;
  tiers : CartQuantityDiscountTier[];
  stackableWithDynamic : Boolean;
}
FieldDescription
enabledWhether this promotion is active.
tiersArray of quantity discount tiers.
stackableWithDynamicWhether this discount can stack with dynamic promotions.
CartQuantityDiscountTier

MPO Version: 1.3.0

A single tier in cart quantity discount promotion.

interface CartQuantityDiscountTier = {
  minQuantity : Integer;
  discountPercent : Double;
  discountAmount : Double;
  customerMessage : String;
}
FieldDescription
minQuantityMinimum total items to activate this tier.
discountPercentPercentage discount to apply.
discountAmountFixed discount amount to apply.
customerMessageMessage to display when this tier applies.

MembershipDiscountPromotion

MPO Version: 1.3.0

Static promotion: Discount based on customer membership level.

interface MembershipDiscountPromotion = {
  enabled : Boolean;
  membershipProperty : String;
  levels : MembershipDiscountLevel[];
  stackableWithDynamic : Boolean;
}
FieldDescription
enabledWhether this promotion is active.
membershipPropertySession property that holds the customer's membership level.
levelsArray of membership levels and their discount percentages.
stackableWithDynamicWhether this discount can stack with dynamic promotions.
MembershipDiscountLevel

MPO Version: 1.3.0

Discount configuration for a specific membership level.

interface MembershipDiscountLevel = {
  membershipLevel : String;
  discountPercent : Double;
  customerMessage : String;
}
FieldDescription
membershipLevelThe membership level name (e.g., silver, gold, platinum).
discountPercentPercentage discount for this membership level.
customerMessageMessage to display to customer.

LoyaltyPointsMultiplierPromotion

MPO Version: 1.3.0

Static promotion: Points multiplier based on membership level.

interface LoyaltyPointsMultiplierPromotion = {
  enabled : Boolean;
  membershipProperty : String;
  defaultMultiplier : Double;
  levels : PointsMultiplierLevel[];
}
FieldDescription
enabledWhether this promotion is active.
membershipPropertySession property that holds the customer's membership level.
defaultMultiplierDefault points multiplier for non-members (typically 1).
levelsArray of membership levels and their point multipliers.
PointsMultiplierLevel

MPO Version: 1.3.0

Points multiplier configuration for a specific membership level.

interface PointsMultiplierLevel = {
  membershipLevel : String;
  multiplier : Double;
}
FieldDescription
membershipLevelThe membership level name.
multiplierPoints multiplier for this level (e.g., 2 for double points).

DynamicPromotionSettings

MPO Version: 1.3.0

Configuration for complex, database-driven promotions evaluated by the Promotion Engine at runtime. When enabled, auto-generates Campaign, Coupon, and CampaignUsage DataObjects.

interface DynamicPromotionSettings = {
  enabled : Boolean;
  supportCoupons : Boolean;
  supportMultipleCoupons : Boolean;
  maxCouponsPerCart : Integer;
  campaignSettings : AutoGeneratedCampaignSettings;
  cacheSettings : PromotionCacheSettings;
}
FieldDescription
enabledWhether dynamic promotions are enabled. Auto-generates Campaign DataObject and adds couponCode/appliedCampaignIds fields to Cart.
supportCouponsWhether to generate the Coupon DataObject for coupon code support.
supportMultipleCouponsWhether multiple coupon codes can be applied to a single cart.
maxCouponsPerCartMaximum coupons per cart (if supportMultipleCoupons).
campaignSettingsConfiguration for the auto-generated Campaign DataObject.
cacheSettingsRedis caching settings for campaign data.

AutoGeneratedCampaignSettings

MPO Version: 1.3.0

Configuration for the auto-generated Campaign DataObject. Controls which features are available for campaigns.

interface AutoGeneratedCampaignSettings = {
  generateAdminApis : Boolean;
  supportBudgetLimits : Boolean;
  supportUsageLimits : Boolean;
  supportCustomerLimits : Boolean;
  supportDailyLimits : Boolean;
  supportScheduling : Boolean;
  supportCustomerTags : Boolean;
}
FieldDescription
generateAdminApisWhether to generate CRUD APIs for campaign and coupon management.
supportBudgetLimitsWhether campaigns can have budget limits (max discount amount to give).
supportUsageLimitsWhether campaigns can have usage limits (max total redemptions).
supportCustomerLimitsWhether campaigns can have per-customer usage limits.
supportDailyLimitsWhether campaigns can have daily usage/budget limits.
supportSchedulingWhether campaigns can have start/end dates and time-of-day rules.
supportCustomerTagsWhether campaigns can target specific customer segments.

PromotionCacheSettings

MPO Version: 1.3.0

Redis caching configuration for promotion campaign data.

interface PromotionCacheSettings = {
  cacheInRedis : Boolean;
  cacheTtlSeconds : Integer;
  cacheKeyPrefix : String;
}
FieldDescription
cacheInRedisWhether to cache active campaigns in Redis for performance.
cacheTtlSecondsTTL for campaign cache in Redis (default: 300 = 5 minutes).
cacheKeyPrefixPrefix for campaign cache keys (default: 'promo:').

ShoppingCartRedisSettings

MPO Version: 1.3.0

Redis caching configuration for cart data enabling hyper-scalable, Redis-first architecture.

interface ShoppingCartRedisSettings = {
  enabled : Boolean;
  keyPrefix : String;
  cartTtlSeconds : Integer;
  itemsTtlSeconds : Integer;
  persistStrategy : RedisPersistStrategy;
  persistIntervalSeconds : Integer;
  useHashForCart : Boolean;
  useListForItems : Boolean;
}
FieldDescription
enabledWhether to use Redis for cart caching.
keyPrefixPrefix for all Redis keys related to this cart type (e.g., 'cart:').
cartTtlSecondsTTL for cart data in Redis. After this time inactive carts are evicted.
itemsTtlSecondsTTL for cart items data in Redis.
persistStrategyWhen to persist cart data to database: 'onEveryChange', 'onCheckout', 'periodic', 'never'.
persistIntervalSecondsInterval for periodic persistence (if persistStrategy is 'periodic').
useHashForCartUse Redis HASH for cart data (better for partial updates) vs STRING (simpler).
useListForItemsUse Redis LIST for items (ordered) vs SET (unordered, faster lookups).

RedisPersistStrategy

Defines when cart data in Redis is persisted to the database.

const RedisPersistStrategy = {
  onEveryChange: "onEveryChange",
  onCheckout: "onCheckout",
  periodic: "periodic",
  never: "never",
};
EnumDescription
onEveryChangePersist to DB on every cart modification. Most durable but highest DB load.
onCheckoutOnly persist when cart is checked out. Abandoned carts may be lost if Redis fails.
periodicPersist on a schedule (see persistIntervalSeconds). Balance of durability and performance.
neverNever persist to DB automatically. Use for pure Redis carts (e.g., anonymous sessions).

ShoppingCartEventSettings

MPO Version: 1.3.0

Event hooks for injecting custom business logic. Each event references a function name from the Service Library.

interface ShoppingCartEventSettings = {
  lifecycleEvents : CartLifecycleEvents;
  itemEvents : CartItemEvents;
  pricingEvents : CartPricingEvents;
  promotionEvents : CartPromotionEvents;
  checkoutEvents : CartCheckoutEvents;
}
FieldDescription
lifecycleEventsEvents for cart creation, loading, and destruction.
itemEventsEvents for item add, update, remove operations.
pricingEventsEvents during price calculation phases.
promotionEventsEvents during promotion evaluation.
checkoutEventsEvents during checkout process.

CartLifecycleEvents

MPO Version: 1.3.0

Event handlers for cart lifecycle. Values are Service Library function names.

interface CartLifecycleEvents = {
  onCartCreate : String;
  onCartLoad : String;
  onCartDestroy : String;
  onCartChurning : String;
  onCartAbandon : String;
}
FieldDescription
onCartCreateCalled when a new cart is created. Context: {cart, session}
onCartLoadCalled when an existing cart is loaded. Context: {cart, items, session}
onCartDestroyCalled when a cart is destroyed. Context: {cartId, session}
onCartChurningCalled when a cart transitions to 'churning' status (inactive for churningPeriodDays). Use this to send reminder emails. Context: {cart, daysSinceLastActivity, session}
onCartAbandonCalled when a cart transitions to 'abandoned' status (inactive for abandonmentPeriodDays). Use this to archive or delete carts. Context: {cart, daysSinceLastActivity, session}

CartItemEvents

MPO Version: 1.3.0

Event handlers for item operations. Values are Service Library function names.

interface CartItemEvents = {
  onBeforeAddItem : String;
  onAfterAddItem : String;
  onBeforeUpdateItem : String;
  onAfterUpdateItem : String;
  onBeforeRemoveItem : String;
  onAfterRemoveItem : String;
  onStockValidation : String;
}
FieldDescription
onBeforeAddItemBefore adding item. Context: {cart, itemData, session}. Return modified itemData or throw CartEventError to reject.
onAfterAddItemAfter item added. Context: {cart, item, session}
onBeforeUpdateItemBefore updating item. Context: {cart, item, changes, session}
onAfterUpdateItemAfter item updated. Context: {cart, item, session}
onBeforeRemoveItemBefore removing item. Context: {cart, item, session}
onAfterRemoveItemAfter item removed. Context: {cart, removedItem, session}
onStockValidationValidate stock availability. Context: {items, session}. Return { itemId: { available: bool, maxQty: int } }

CartPricingEvents

MPO Version: 1.3.0

Event handlers for pricing calculations. Values are Service Library function names.

interface CartPricingEvents = {
  onBeforeCalculate : String;
  onCalculateItemPrice : String;
  onCalculateVat : String;
  onCalculateShipping : String;
  onAfterCalculate : String;
}
FieldDescription
onBeforeCalculateBefore calculation starts. Context: {cart, items, session}
onCalculateItemPriceFor each item. Context: {cart, item, session}. Return modified pricing or null.
onCalculateVatDuring VAT calculation. Context: {cart, item, session}. Return {vatRate, exempt} for tax-exempt scenarios.
onCalculateShippingCalculate shipping. Context: {cart, items, session}. Return {chargeExVat, vatRate}
onAfterCalculateAfter all calculations. Context: {cart, items, totals, session}. Return modified totals.

CartPromotionEvents

MPO Version: 1.3.0

Event handlers for promotion evaluation. Values are Service Library function names.

interface CartPromotionEvents = {
  onBeforePromotionEvaluation : String;
  onPromotionEvaluation : String;
  onAfterPromotionEvaluation : String;
  onApplyCoupon : String;
}
FieldDescription
onBeforePromotionEvaluationBefore engine runs. Context: {cart, items, session}
onPromotionEvaluationAdd custom promotions. Context: {cart, items, appliedPromotions, session}. Return additional promotions.
onAfterPromotionEvaluationAfter promotions determined. Context: {cart, items, promotions, session}. Can filter/modify.
onApplyCouponCoupon validation. Context: {cart, couponCode, session}. Return {valid, message} or throw error.

CartCheckoutEvents

MPO Version: 1.3.0

Event handlers for checkout process. Values are Service Library function names.

interface CartCheckoutEvents = {
  onBeforeCheckout : String;
  onReserveStock : String;
  onCreateOrder : String;
  onAfterCheckout : String;
  onCheckoutFailed : String;
}
FieldDescription
onBeforeCheckoutBefore checkout. Context: {cart, items, session}. Throw CartEventError to block.
onReserveStockReserve inventory. Context: {cart, items, session}. Return {success, failedItems}
onCreateOrderCreate order from cart. Context: {cart, items, session}. Return {orderId}
onAfterCheckoutAfter successful checkout. Context: {cart, orderId, session}
onCheckoutFailedOn failure. Context: {cart, error, session}. Handle cleanup.

ShoppingCartApiSettings

MPO Version: 1.3.0

Configuration for auto-generated cart management API routes.

interface ShoppingCartApiSettings = {
  routePrefix : String;
  authenticationRequired : Boolean;
  rateLimiting : Boolean;
  maxRequestsPerMinute : Integer;
  enabledRoutes : CartApiRoutes;
}
FieldDescription
routePrefixURL prefix for cart routes (e.g., '/cart'). Default: '/{cartObjectName}'.
authenticationRequiredWhether authentication is required. False allows guest carts.
rateLimitingEnable rate limiting on cart APIs.
maxRequestsPerMinuteRate limit: max requests per minute per user/session.
enabledRoutesWhich cart routes to generate.

CartApiRoutes

MPO Version: 1.3.0

Which cart API routes to generate. All default to true.

interface CartApiRoutes = {
  getCart : Boolean;
  addItem : Boolean;
  updateItem : Boolean;
  removeItem : Boolean;
  clearCart : Boolean;
  applyCoupon : Boolean;
  removeCoupon : Boolean;
  redeemPoints : Boolean;
  checkout : Boolean;
  recalculate : Boolean;
}
FieldDescription
getCartGET /{prefix} - Retrieve current cart with items and totals.
addItemPOST /{prefix}/items - Add item to cart by productId or barcode.
updateItemPUT /{prefix}/items/:itemId - Update item quantity.
removeItemDELETE /{prefix}/items/:itemId - Remove item from cart.
clearCartDELETE /{prefix}/items - Clear all items from cart.
applyCouponPOST /{prefix}/coupon - Apply a coupon code.
removeCouponDELETE /{prefix}/coupon - Remove applied coupon.
redeemPointsPOST /{prefix}/points - Redeem loyalty points (if loyalty enabled).
checkoutPOST /{prefix}/checkout - Begin checkout process.
recalculatePOST /{prefix}/recalculate - Force recalculation.

ShoppingCartCheckoutSettings

MPO Version: 1.3.0

Configuration for cart-to-order checkout process. Defines how checkout converts a cart into an order, including property mapping, order creation mode, and event publishing.

interface ShoppingCartCheckoutSettings = {
  orderCreationMode : OrderCreationMode;
  orderDataObjectName : String;
  autoMapProperties : Boolean;
  propertyMappings : CartToOrderPropertyMapping[];
  orderDataClause : MScript;
  publishCheckoutEvent : Boolean;
  checkoutEventTopic : String;
  initialOrderStatus : String;
}
FieldDescription
orderCreationModeHow to create orders from cart: 'local' creates order in same service, 'remote' publishes event for external order service, 'none' skips order creation.
orderDataObjectNameName of the order DataObject in this service. Required when orderCreationMode is 'local'. The system will auto-detect if there's a DataObject with isOrder flag.
autoMapPropertiesIf true, automatically map cart properties to order properties (userId, subtotal, total, etc.).
propertyMappingsOverride specific cart-to-order property mappings when autoMapProperties isn't sufficient.
orderDataClauseJavaScript code injected into order creation for custom properties. Access cart as 'cart', items as 'cartItems', and session context as 'this'. Example: 'salesChannel: "web", referralCode: this.metadata?.referral'
publishCheckoutEventWhether to publish a checkout completed event to Kafka. Always true when orderCreationMode is 'remote'.
checkoutEventTopicKafka topic for checkout events. Default: '{serviceCodename}-cart-checkout-completed'
initialOrderStatusInitial status to set on created orders. Usually 'pending' or 'awaiting_payment'.

OrderCreationMode

How checkout creates orders from the shopping cart.

const OrderCreationMode = {
  local: "local",
  remote: "remote",
  none: "none",
};
EnumDescription
localCreate the order directly in this service using the specified orderDataObjectName.
remotePublish a checkout event for an external order service to consume and create the order.
noneDo not create an order automatically. Use this when custom order creation logic is needed.

CartToOrderPropertyMapping

MPO Version: 1.3.0

Maps a cart property to an order property, optionally with a transformation.

interface CartToOrderPropertyMapping = {
  cartProperty : String;
  orderProperty : String;
  transform : MScript;
}
FieldDescription
cartPropertyThe cart property path to read from (e.g., 'grandTotalIncVat', 'userId', 'items').
orderPropertyThe order property to write to (e.g., 'totalAmount', 'customerId').
transformOptional MScript expression to transform the value. Use 'value' to reference the cart property value.