Home › Forums › Custom Shipping Methods for WooCommerce › How to calculate with a table if we charge client per km of delivery? › Reply To: How to calculate with a table if we charge client per km of delivery?
The idea is really interesting and I would gladly implement it in plugin, however there is one major problem – plugin would need to know the distance between your shop and the customer. For plugin to calculate the distance, it would need to know the coordinates (i.e. latitude and longitude) of both your shop and the customer. In standard WooCommerce setup, customer enters ZIP code, so we could try go get latitude and longitude from ZIP code, but this would definitely require some external API, which would connect ZIP codes with coordinates. If you have any thoughts on how to solve this – please let me know.
Simple solution would be acceptable if your shop deliver to small (or at least finite) number of ZIP codes – in this case we could manually pre-fill the table of ZIP codes -> distances. Hope you get the idea…