Line Item Apportioning

Rolled-up vs Split Line Items

The dovetech promotion engine can be passed line items that are split out (i.e. a quantity of 1 per-line item) or rolled-up (i.e. multiple quantities per line item).

If you pass line items with multiple quantities then any discounts will be returned with a subItemId. For example, passing a basket with a quantity like below:

{
  "basket": {
    "items": [
      {
        "quantity": 2,
        "price": 60
      }
    ]
  }
}

If a 50% off basket discount applies, the basket will be returned like so:

{
  "basket": {
    "total": 60,
    "totalAmountOff": 60,
    "items": [
      {
        "total": 60,
        "totalAmountOff": 60,
        "actions": [
          {
            "id": "a0f9cc85-fd3b-4e13-a83f-f2c4cdeb4a26",
            "subItemId": 1,
            "amountOff": 30
          },
          {
            "id": "a0f9cc85-fd3b-4e13-a83f-f2c4cdeb4a26",
            "subItemId": 2,
            "amountOff": 30
          }
        ]
      }
    ]
  }
}

You can see the API returns two sub items with the amount apportioned between them. The overall total and totalAmountOff are returned for the line item.

If you pass line items split out like so:

{
  "basket": {
    "items": [
      {
        "quantity": 1,
        "price": 60
      },
      {
        "quantity": 1,
        "price": 60
      }
    ]
  }
}

The items are returned as they are passed in the request:

{
  "basket": {
    "total": 60,
    "totalAmountOff": 60,
    "items": [
      {
        "total": 30,
        "totalAmountOff": 30,
        "actions": [
          {
            "id": "7aa4aba8-d8f9-4559-90ce-e448b75c924f",
            "subItemId": 1,
            "amountOff": 30
          }
        ]
      },
      {
        "total": 30,
        "totalAmountOff": 30,
        "actions": [
          {
            "id": "7aa4aba8-d8f9-4559-90ce-e448b75c924f",
            "subItemId": 1,
            "amountOff": 30
          }
        ]
      }
    ]
  }
}

Rounding

If the discount cannot be apportioned equally across line items (according to the currency minor unit digits) then amounts are apportioned so they sum to the correct amount. E.g. if you provide a basket like so:

{
  "basket": {
    "items": [
      {
        "quantity": 2,
        "price": 58.99
      }
    ]
  }
}

The amount is apportioned differently:

{
  "basket": {
    "total": 58.99,
    "totalAmountOff": 58.99,
    "items": [
      {
        "total": 58.99,
        "totalAmountOff": 58.99,
        "actions": [
          {
            "id": "de38d689-a412-4107-8c2d-f5349bbcbd11",
            "subItemId": 1,
            "amountOff": 29.5
          },
          {
            "id": "de38d689-a412-4107-8c2d-f5349bbcbd11",
            "subItemId": 2,
            "amountOff": 29.49
          }
        ]
      }
    ]
  }
}

Note, this example is in GBP which has 2 minor unit digits. If the currency was KWD which has 3 minor unit digits then the amountOff would be 29.495

Amount Off Line Item

If an amount off line item discount is limited to apply to only 1 line item then the amount is not apportioned over line items. E.g. for a buy 3 get 1 free discount, if you pass in a basket with 3 items like so:

{
  "basket": {
    "items": [
      {
        "quantity": 3,
        "price": 58.99
      }
    ]
  }
}

Then the discount will be applied to one sub-item:

{
  "basket": {
    "total": 117.98,
    "totalAmountOff": 58.99,
    "items": [
      {
        "total": 117.98,
        "totalAmountOff": 58.99,
        "actions": [
          {
            "id": "1202b12a-de77-4b71-a77b-1f795057c481",
            "subItemId": 1,
            "amountOff": 58.99
          }
        ]
      }
    ]
  }
}