PHP code example of stas-plov / jde-shipping

1. Go to this page and download the library: Download stas-plov/jde-shipping 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/ */

    

stas-plov / jde-shipping example snippets


$jdeShipping = new JdeShipping();

$jdeShipping->setUser('1234');
$jdeShipping->setToken('1234');

$geo = new GeoSearchRequest();
$geo ->setMode(1);

$result = $jdeShipping->getGeoSearch($geo);

$shipmentCalc = (new ShipmentCostCalcByAddressRequest())
	->setAddrFrom('владивосток')
	->setAddrTo('москва')
	->setType(1)
	->setWeight(2.167)
	->setWidth(0.121)
	->setHeight(0.121)
	->setLength(2.135)
	->setQuantity(1)
	->setPickup(1)
	->setDelivery(1)
	->setDeclared(3670)
	->setOversizeWeight(1)
	->setOversizeVolume(1)
	->setObrVolume(0.031);

$result = $this->jdeShipping->getShipmentCostCalcByAddress($shipmentCalc);

if($result->isOk()) {
	$cost = $result->getPrice();
}

$shipmentCalc = (new ShipmentCostCalcRequest())
	->setFrom('1010005858')
	->setTo('1125904247254472')
	->setType(1)
	->setWeight(216)
	->setVolume(0.41);

$result = $this->jdeShipping->getShipmentCostCalcByAddress($shipmentCalc);

if($result->isOk()) {
	$cost = $result->getPrice();
}

$shipmentCalc = (new ShipmentCostCalcRequest())
	->setFrom('Москва')
	->setTo('Владивосток')
	->setType(1)
	->setWeight(216)
	->setVolume(0.41)
	->setSmart(true);
	

$result = $this->jdeShipping->getShipmentCostCalcByAddress($shipmentCalc);

if($result->isOk()) {
	$cost = $result->getPrice();
}


$order = (new OrderCreateRequest())
	->setFrom("1125899906842653")
	->setTo("1125899906842629")
	->setVolume(1)
	->setWeight(1)
	->setPositions(2)
	->setGruzdesc("Бытовая техника и электроника")
	->setPayer(JdeShipping::PAYER_SENDER)
	->setSender(
		(new PersonSender)
			->setAddr("Санкт-Петербург, Невский 30-2-12")
			->setTitle("ООО Отправитель")
			->setPhone("+79110000000")
	)
	->setReceiver(
		(new PersonReceiver)
			->setAddr("г. Москва, ул. 2-й Лучевой просек, д. 5В")
			->setTitle("ООО Получатель")
			->setPhone("+79110000000")
	);

$result = $this->jdeShipping->sendOrderCreate($geoKladr);

$orderNumber = $result->getOrderNumber();

$geoKladr = new OrderListRequest();

$response = $this->jdeShipping->getOrderList($geoKladr);

if(!empty($result)) {
	$id = $result[0]->getId();
	$cargoStatus = $result[0]->getInfo()->getCargostatus()
}

$geoKladr = (new GeoSearchByKladrRequest())
	->setKladrCode('5002700102400');

$result = $this->jdeShipping->getGeoSearchByKladr($geoKladr);

if(!empty($result)) {
	$city = $result[0]->getCity();
	$address = $result[0]->getAddr();
}