PHP code example of sima-land / delivery-calculator

1. Go to this page and download the library: Download sima-land/delivery-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/ */

    

sima-land / delivery-calculator example snippets


$calc = new Calculator($defaultVolumeFactor, $point, false)

$calc->addItem($item1, 10)
$calc->addItem($item2, 1000)
echo $calc->getResult();  // вывод стоимости доставки item1 10 шт. и item2 1000 шт.

$calc->reset();
$calc->addItem($item3, 1)
echo $calc->getResult(); // вывод стоимости доставки item3 1 шт. 

// $item4->getWeight() = 0
if (!$calc->addItem($item4, 1000)) {
	return $calc->getErrors() // ['Weight must be positive, weight=0']
}