Pakettikauppa / api-library

A PHP library for Pakettikauppa API
MIT License
3 stars 6 forks source link

Ability to get shipping cost estimations for multiple shipping methods in a single API call? #21

Open nicodemuz opened 3 years ago

nicodemuz commented 3 years ago

Hi,

I would like to inquire whether it's possible to get shipping cost estimations from multiple shipping methods with a single API call?

I'm currently building an online shop that allows the customer to choose the shipping method. However, showing the estimated cost takes a lot of time as it has to be done using multiple API calls.

I'm hoping to be able to render something like this:

Screenshot from 2021-07-07 23-10-39

I welcome also any other suggestions for improvement.

nicodemuz commented 2 years ago

@joosev is it possible to get an API end-point for this?

joosev commented 2 years ago

There is no option to get multiple shipping estimates with one API call at the moment

Estimation is implemented in the: https://github.com/Pakettikauppa/api-library/blob/4c2a89bb5644e5cb6c3dba06679d227fba0df1b0/src/Pakettikauppa/Client.php#L323

So the end point is: /shipment/estimate-price

joosev commented 2 years ago

The problem with multiple options for shipment has a problem because consumer does not know what those options are and which are possible. For example "Pikkupaketti" is product name for busineses only and has a size limit of 35,3 cm x 25 cm x 3 cm

Also With Matkahuolto shipments we can't create any estimation for the shipments for now, because Matkahuolto only allows to use own merchant contract with them and they don't have API to give use price estimation. Express-paketti and Jakopaketti are also B2B shipping methods and not available for consumers. XXS-paketti has also size limit and Bussi paketti is only good for certain kind of goods.

So it is better to choose the correct shipping methods wisely. And some of those shipping methods would require usage of pickup point search to make it work better - f.ex. XXS-paketti, lähellä-paketti and Bussi-paketti requires that and if not provded one, Pakettikauppa will just guess the best one based on distance, but it might not be the best one for the customer.

nicodemuz commented 2 years ago

@joosev would be great if there was an end-point where I can describe my shipment (size, weight, sender address, receiver address, business/personal, type of goods, etc), and the end-point would return a list of compatible shipping methods with estimations.

I'm currently still developing an interface for selecting the shipping method like this:

Screenshot from 2022-02-19 09-38-43

Is this the recommended approach?

You mentioned Matkahuolto doesn't have API to give price estimation. But I'm still able to get price estimations via the API? (see screenshot)

joosev commented 2 years ago

it is pretty rare cases where actual cost in domestic shippings would have any correlation to the actual cost of shipping. But at the moment, no, you can not ask for multiple different prices, only one. Cost is not the only factor why merchant wants to use some specific shipping method. For example sustainable options, speed, pickup point network, drop off locations, etc...

Normally merchants offer like home delivery and pickup point options. and maybe from 2 different providers.

Because MH support has just changed, it seems that the price estimation API has still some MH related stuff in it. Currently,Pakettikauppa does not know the shipping price of MH shipments because it is agreed in the contract between merchant and Matkahuolto and Matkahuolto does not provide API to ask that.

joosev commented 2 years ago

The list-shipping-methods method though might make sense to have some parameters to filter out the results, for example by receiving county parameter.

Usually the list shipping methods API call is used in the backend to provide options for the merchant which merchant then chooses to use. It is not normally used at the checkout.