PHP code example of nanoblocktech / shipping-calculator
1. Go to this page and download the library: Download nanoblocktech/shipping-calculator library. Choose the download type require. 2. Extract the ZIP file and open the index.php. 3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
nanoblocktech / shipping-calculator example snippets
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";