promotion-calculation-engine

inCart open source package for E-Commerce Platform Promotion Calculation.

Usage no npm install needed!

<script type="module">
  import promotionCalculationEngine from 'https://cdn.skypack.dev/promotion-calculation-engine';
</script>

README

Promotion Calculation Engine

Utility Promotion Calculation with TypeScript

Installation

Use the node package manager npm to install foobar.

npm install

recommended node version: 12

How Calculation Engine Works

[Rules] -> [Calculate Engine] -> [Calculated Result]

Usage

import { CalculationEngine } from 'promotion-calculation-engine'

const calculationEngine = new CalculationEngine()
const calculateOrder = await calculationEngine.process({
    rules,
    items,
    deliveryAddresses,
    customer: {
      uniqueId: customer.id,
      email: customer.email,
      msisdn: customer.mobileNo,
      isNewCustomer: customer.isNewCustomer,
    } || null,
    usageCounts: [{
       salesRuleId: rule.id,
       total: 10,
       byCustomer: 1
    }],
  }, {
  
})
  

Test and Development

See example rules in test folder

To run all test rules use command

npm run test or yarn test