There is no license information available for the latest version (dev-master) of this package.

This bundle provides integration with ECONT Courier. Module is based on Bozhidar Hristov's vm/econt.

Maintainers

Details

github.com/todstoychev/econt

Source

Installs: 32

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 6

Type:component

dev-master 2018-03-15 05:29 UTC

This package is not auto-updated.

Last update: 2024-04-14 02:45:31 UTC


README

PHP Component to integrate with ECONT Courier

So far only calculation is possible.

$guzzle = new \GuzzleHttp\Client();
$client = new \Todstoychev\Econt\Client($guzzle, true, 'demo', 'demo');

$parcelRequest = new \Todstoychev\Econt\Request\ParcelRequest();
$parcelRequest->setOnlyCalculate(true);


$loading = new \Todstoychev\Econt\Model\Loading();

$sender = new \Todstoychev\Econt\Model\Sender();
$sender->setCountryCode('BRG');
$sender->setCity('София');
$sender->setPostCode('1000');
$loading->setSender($sender);


$receiver = new \Todstoychev\Econt\Model\Receiver();
$receiver->setCountryCode('BRG');
$receiver->setCity('Бургас');
$receiver->setPostCode('80001');
$loading->setReceiver($receiver);


$shipment = new \Todstoychev\Econt\Model\Shipment();
$shipment->setShipmentType(\Todstoychev\Econt\Model\Shipment::SHIPMENT_TYPE_PACK);
$shipment->setPackCount(1);
$shipment->setWeight(1);
$shipment->setTariffSubCode(\Todstoychev\Econt\Model\Shipment::TARIFF_SUB_CODE_DOOR_DOOR);
$loading->setShipment($shipment);

$parcelRequest->addLoading($loading);

/** @var \Todstoychev\Econt\Response\ParcelResponse $response */
$response = $client->execute($parcelRequest);

foreach ($response->getParcelResults() as $parcelResult) {
    if ($parcelResult->hasError()) {
        echo 'Грешка: ';
        foreach ($parcelResult->getError()->getMessages() as $errorMsg) {
            echo $errorMsg;
        }

    } else {
        echo 'Цена за доставка '.$parcelResult->getLoadingPrice()->getTotal().' '.$parcelResult->getLoadingPrice()->getCurrency()->getName();
    }
}

Example output with error:

Грешка: получател: Не е намерено населено място с пощенски код 80001

Example output without error:

Цена за доставка 7.8 лв