You can add to the built-in allocation rules by excluding certain carrier services that would otherwise be returned as being the lowest cost option, leaving only those services that can adequately fulfil all the requirements of the particular order.
This is done using the following GUI in Delivery Manager:
The interface is based on creating weighting rules by excluding or favouring certain carrier services in particular circumstances. However, for the purposes of Delivery Options we will use the same interface, but use Custom
scoring rules (as, for example, used in creating Next Day Allocation Rules).
After you select Custom
as the Rule type
, you can complete the Carrier service
and scoring fields, e.g.
The simplest way to create a scoring rule is to select a carrier service, and then evaluate a Boolean expression that returns a score of -1
if true
. A score of -1
will prevent that service from being returned by Delivery Options when the associated delivery criteria are true
.
In the above example, the selected carrier service will not be returned if the order is associated with one of the hazmat_codes. The full rule when written out is:
Test: (consignment.warehousecode==9963), Score: IIF (consignment.hazardous, -1, score)
If we were now to introduce the hazmat_codes parameter into the API call used in Using the built-in Allocation Engine:
GET https://dmo.metapack.com/dmoptions/find?key=<API-Key>&wh_code=SL123&c_pc=SL10AG&optionType=HOME&r_t=lsc&incgrp=NEXT&hazmat_codes=1
then the 'DPD BEFORE 10 - Early Cut off' service would be excluded from the example previously shown in Using the built-in Allocation Engine:
{ "header": { "requestId": "0e092882-c9e9-48fd-af62-29a8bb631f56", "requestDate": "2020-03-20T17:24:42.393Z", "inputParameters": { "optionType": [ "HOME" ], "c_pc": [ "SL10AG" ], "r_t": [ "lsc" ], "hazmat_codes": [ "1" ], "wh_code": [ "SL123" ], "key": [ "<API-Key>" ], "incgrp": [ "NEXT" ] }, "responseDate": "2020-03-20T17:24:42.505Z" }, "results": [ { "groupCodes": [ "NEXT" ], "photoUrls": [], "telephoneNumber": null, "distance": { "unit": "m", "value": 0 }, "description": null, "carrierServiceCode": "HERMNDG", "long": null, "optionType": "HOME", "countryCode": null, "storeName": "", "shippingCharge": 0, "lat": null, "delivery": { "from": "2020-03-21T08:00:00.000Z", "to": "2020-03-21T20:00:59.999Z" }, "address": "", "carrierServiceName": "Courier Service Next Day", "postcode": "", "fullName": "Hermes Courier Service Next Day", "collection": { "from": "2020-03-20T18:30:00.000Z", "to": "2020-03-20T19:30:59.999Z" }, "storeId": null, "logoUrl": null, "storeTimes": {}, "carrierCode": "HERMESPOS", "hasDisabledAccess": false, "bookingCode": "HERMNDG/2020-03-20/*-*/*/*-*", "cutOffDateTime": "2020-03-20T18:00:00.000Z" }, { "groupCodes": [ "NEXT" ], "photoUrls": [], "telephoneNumber": null, "distance": { "unit": "m", "value": 0 }, "description": null, "carrierServiceCode": "RM1STLT", "long": null, "optionType": "HOME", "countryCode": null, "storeName": "", "shippingCharge": 3, "lat": null, "delivery": { "from": "2020-03-21T08:00:00.000Z", "to": "2020-03-21T17:00:59.999Z" }, "address": "", "carrierServiceName": "1st Class Letter", "postcode": "", "fullName": "Royal Mail 1st Class Letter", "collection": { "from": "2020-03-20T18:30:00.000Z", "to": "2020-03-20T19:30:59.999Z" }, "storeId": null, "logoUrl": null, "storeTimes": {}, "carrierCode": "ROYALMAIL", "hasDisabledAccess": false, "bookingCode": "RM1STLT/2020-03-20/*-*/*/*-*", "cutOffDateTime": "2020-03-20T18:00:00.000Z" } ]
Now, let us say that wanted to we will create a rule to exclude services that are not able to handle certain weights of package.
To continue the previous code example, you may wish to exclude 'Hermes Courier Service Next Day' because it is not equipped to deal with packages over 5 kilograms from the warehouse in question. You can create a rule to exclude the service from being returned for packages from that warehouse that weigh in excess of this:
Test: (consignment.warehousecode==9963), Score: IIF (consignment.weight > 5, -1, SCORE)
Now, when we run the same query, but with e_w=10.0
(refer to e_w) as the final parameter (instead of the the hazmat_codes
parameter):
GET https://dmo.metapack.com/dmoptions/find?key=<API-Key>&wh_code=SL123&c_pc=SL10AG&optionType=HOME&r_t=lsc&incgrp=NEXT&e_w=10.0
'Hermes Courier Service Next Day' is excluded (together with Royal Mail, already excluded owing to the built-in allocation rules):
{ "header": { "requestId": "60c76861-cece-44cc-b3b6-58b71c41b4dc", "requestDate": "2020-03-20T17:07:41.834Z", "inputParameters": { "optionType": [ "HOME" ], "c_pc": [ "SL10AG" ], "r_t": [ "lsc" ], "e_w": [ "10.0" ], "wh_code": [ "SL123" ], "key": [ "<API-Key>" ], "incgrp": [ "NEXT" ] }, "responseDate": "2020-03-20T17:07:41.921Z" }, "results": [ { "groupCodes": [ "NEXT" ], "photoUrls": [], "telephoneNumber": null, "distance": { "unit": "m", "value": 0 }, "description": null, "carrierServiceCode": "PLPRE1000OC", "long": null, "optionType": "HOME", "countryCode": null, "storeName": "", "shippingCharge": 4, "lat": null, "delivery": { "from": "2020-03-20T08:00:00.000Z", "to": "2020-03-20T10:00:59.999Z" }, "address": "", "carrierServiceName": "BEFORE 10 - Early Cut off", "postcode": "", "fullName": "DPD BEFORE 10 - Early Cut off", "collection": { "from": "2020-03-20T18:30:00.000Z", "to": "2020-03-20T19:30:59.999Z" }, "storeId": null, "logoUrl": null, "storeTimes": {}, "carrierCode": "DPD", "hasDisabledAccess": false, "bookingCode": "PLPRE1000OC/2020-03-20/*-*/*/*-*", "cutOffDateTime": "2020-03-20T18:00:00.000Z" } ] }