Hello Carleto,
The cost calculation shortcodes must be part of the Cost field.
There are multiple ways in which the cost per distance could be calculated. Sharing some of the examples so you can try those out as per your needs:
Table Rate Shipping
[costs_table prop="distance" table="0-0|16-35|30-50|70-60" key="API_KEY" default_distance="100" units="km" debug="yes"]
The above would calculate shipping based on below table:
Distance
Shipping Cost
from 0 and below 16 km
0
from 16 and below 30 km
35
from 30 and below 70 km
50
from 70 km
60
Distance based calculation
1.5*[distance key="API_KEY" default_distance="15" debug="yes" units="km"]
This would charge a flat fee of 1.5 times the distance.
The above shortcodes must be added to the Cost field in the custom shipping method that will be configured under Shipping Methods of WooCommerce.
Please let me know if you need further assistance in setting up.
Best Regards,
Dhruvin