nanoblocktech/shipping-calculator

PHP类,根据客户从业务地点的纬度和经度确定运费。

1.4 2023-11-21 00:34 UTC

This package is auto-updated.

Last update: 2024-09-21 19:58:07 UTC


README

根据客户到业务地点的经纬度确定运费。

函数

  • 计算业务地点和客户地点之间的距离
  • 根据提供的每距离费用确定运费
  • 根据距离和速度确定预计行驶时间

通过Composer的安装指南

composer require nanoblocktech/shipping-calculator

用法

use Luminova\ExtraUtils\ShippingCalculator;

$calculator = new ShippingCalculator();

// Set business and customer locations

$calculator->setOrigin(6.47427, 7.56196); // Business location (Enugu Airport Nigeria)
$calculator->setDestination(6.51181, 7.35535); // Customer location (Udi Nigeria)
$calculator->setCharge(100); // Initial shipping cost per distance km, or ml

// Calculate distance and return new ShippingDistance instance class

$distance = $calculator->getDistance();

// Get the estimated time information

$time = $calculator->getTime();

// Get your calculated information

echo "Distance: $distance->toDistance() \n";
echo "Distance[km|ml]: $distance->toString() \n";
echo "Shipping Fee: $distance->getCurrency(2)\n";
echo "Shipping Fee: $distance->getCharges()\n";

方法

ShippingCalculator

设置计算 $calculator = new ShippingCalculator(ShippingCalculator::KM);

ShippingDistance

返回方法的代码为 $distance = $calculator->getDistance();

ShippingTime

返回方法的代码为 $time = $distance->getTime();