This article targets developers looking to retrieve drop points with the method GetShipAdvise.
Note: This is only to show a basic example.
You need to apply your own business logic and error handling.
Content in this article:
- The GetDropPoints method
- Get data for one drop point when the user selects a product
- Get all drop points data at once
- Using your own stores as drop points
- Shipping Rules
The GetDropPoints method
This method requires that the data object contain a product id, how many drop points to retrieve, services and the receiver address ("Kind": 1)
Note: ResultCount is min 1 - max 10
Example of the Data object
{
"ProdCSID": 5748,
"ResultCount": 10,
"Addresses": [
{
"Kind": 1,
"Name1": "John Doe",
"Street1": "Test address 1",
"PostCode": "8210",
"City": "Aarhus V",
"CountryCode": "DK"
}
],
"Services": [
676008
]
}
Get data for one drop point when the user selects a product
This approach would be used if you only wanted to request drop point information after the user has selected one of the products returned from the GetShipAdvise method.
Example of a response from the GetDropPoints method when called using a function similar to the one below.
The method takes the freight product selected by the customer and the shipment data.
Then it calls the GetDropPoint method and adds the response to the product object.
const getDropPointData = async (product, shipmentData) => {
let data = {
ProdCSID: product.ProdCSID,
ResultCount: 10,
Addresses: [shipmentData.Addresses.find(x => x.Kind == 1)]
}
if (product.Services) {
request["Services"] = product.Services.map((x) => x.serviceid)
}
let { DropPoints } = await GetDropPoints(data)
product.DropPoints = DropPoints
return product
}
Get all drop points data at once
The method GetShipAdvise does not call the GetDropPoints method by itself. The two methods need to be combined in order for the response from GetShipAdvise to contain drop points.
Example of the default response from the GetShipAdvise method.
As we can see there are no drop point data on the product, but we can see if a product supports it.
In order to get a response as in the sample below.
You need to call the GetDropPoint method before returning the GetShipAdvise response on the products that support drop points and should have drop points returned.
Note: Some products can be used as both a Home Delivery and a Drop Point.
In this sample, the products in the CSR configuration file have a Custom field "isDropPoint" that indicates if the GetDropPoint method should be called on them or not.
const getProductsWithDropPointData = async (shipmentData) => {
let products = await GetShipAdvise(shipmentData)
let productsWithDropPointSupport = products.Products
.filter(x => x.SupportsDropPoint)
.filter(x => x.CustomFields && x.CustomFields.isDropPoint)
productsWithDropPointSupport.map(async (product) => {
let data = {
ProdCSID: product.ProdCSID,
ResultCount: 10,
Addresses: [shipmentData.Addresses.find(x => x.Kind == 1)]
}
if (product.Services) {
request["Services"] = product.Services.map((x) => x.serviceid)
}
let { DropPoints } = await GetDropPoints(data)
product.DropPoints = DropPoints
})
return products
}
Using your own stores as drop points
In order for the GetDropPoint method to be able to return your stores as drop points.
You need to fill out the following template. If more than one drop point is needed then add another <DropPointData> element.
If you don't have the longitude and Latitude use 0.01 as the value for both.
<MapRefX>0.01</MapRefX>
<MapRefY>0.01</MapRefY>
MapRefX for the longitude and MapRefY for the Latitude.
Example with all fields
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfDropPointData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<DropPointData>
<OriginalId>Test01</OriginalId>
<RoutingCode></RoutingCode>
<Depot/>
<Name1>nShift A/S</Name1>
<Name2/>
<Address1>Bredskifte Allé 11</Address1>
<Address2/>
<PostalCode>8210</PostalCode>
<City>Aarhus V</City>
<Region/>
<County/>
<District/>
<Province/>
<State/>
<CountryCode>DK</CountryCode>
<Contact>Test Contact</Contact>
<Phone>11 22 33 44</Phone>
<Email></Email>
<Fax/>
<MapRefX>10.135106</MapRefX>
<MapRefY>56.173088</MapRefY>
<OpeningHoursList>
<OpeningHours>
<Day>Monday</Day>
<Open>09:00</Open>
<Close>21:00</Close>
</OpeningHours>
<OpeningHours>
<Day>Tuesday</Day>
<Open>05:00</Open>
<Close>15:30</Close>
</OpeningHours>
</OpeningHoursList>
</DropPointData>
</ArrayOfDropPointData>
Click here to download the template.
A bit more compact version.
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfDropPointData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<DropPointData>
<OriginalId>01</OriginalId>
<Name1>nShift A/S</Name1>
<Address1>Bredskifte Allé 11</Address1>
<PostalCode>8210</PostalCode>
<City>Aarhus V</City>
<CountryCode>DK</CountryCode>
<Contact>Test Contact</Contact>
<Phone>11 22 33 44</Phone>
<MapRefX>10.132236331701279</MapRefX>
<MapRefY>56.179632447054956</MapRefY>
</DropPointData>
</ArrayOfDropPointData>
Click here to download the template.
Note: Multiple files are supported and each file should not contain more than 1000 drop points.
The file needs to be sent to the local customer service, they will create a custom product and add the list to it.
If you need a special name for it the custom product e.x "Collect @ Store" then you need to specify this in the email.
Shipping Rules
The configuration file containing the products used for the GetShipAdvise method in this article.
<?xml version="1.0" encoding="utf-8"?>
<CSR carriervalidation="0" defaultservicelevel="Service_Level_Configured_For_SA">
<Prices>
<Price name="fixed59" currency="DKK">
<Exceptions>
<Exception price="5900">
<ValidationRules>
</ValidationRules>
</Exception>
</Exceptions>
<Fees>
<Fee price="1900">
<ValidationRules>
</ValidationRules>
</Fee>
</Fees>
</Price>
<Price name="fixed39" currency="DKK">
<Exceptions>
<Exception price="3900">
<ValidationRules>
</ValidationRules>
</Exception>
</Exceptions>
</Price>
</Prices>
<ServiceLevels>
<ServiceLevel name="Service_Level_Configured_For_SA">
<Products>
<Product adviseprice="fixed39" name="GLS DK - Pakkeshop med Drop Points" conceptid="1551">
<ProductGoodsType goodstypeid="0"/>
<CustomFields type="Pickup Point" servicecode="P1"/>
<ValidationRules>
<ValidationRule name="country" allowcountries="DK" field="fld_AdrCountry"/>
</ValidationRules>
</Product>
<Product adviseprice="fixed59" name="GLS DK - Normal erhvervspakke" conceptid="113">
<ProductGoodsType goodstypeid="0"/>
<CustomFields type="Home Delivery" servicecode="P2"/>
<ValidationRules>
<ValidationRule name="country" allowcountries="DK" field="fld_AdrCountry"/>
</ValidationRules>
<Services>
<Service serviceid="11020" name="Private Delivery Service"/>
</Services>
</Product>
<Product adviseprice="fixed59" name="GLS DK - Export" conceptid="189">
<ProductGoodsType goodstypeid="0"/>
<CustomFields type="Home Delivery" servicecode="P3"/>
<ValidationRules>
<ValidationRule name="country" allowcountries="SE" field="fld_AdrCountry"/>
</ValidationRules>
</Product>
</Products>
</ServiceLevel>
</ServiceLevels>
</CSR>