Advertising sustains the DA. Ads are hidden for members. Join today

On this page

Code examples

Last updated on
29 March 2019

Drupal 7 will no longer be supported after January 5, 2025. Learn more and find resources for Drupal 7 sites

API methods

Get a list of order pickup points.

$cdek = Cdek::getInstance();
$points = $cdek->getOrderPickupPoints();

Get a list of order pickup points that match the specified parameters.

$cdek = Cdek::getInstance();
$points = $cdek->getOrderPickupPoints(array(
 'countryid' => 1,
 'cityid' => 44,
 'type' => 'PVZ',
 'allowedcod' => TRUE,
 'weightmax' => 100,
));

Get a list of countries.

$cdek = Cdek::getInstance();
$countries = $cdek->getCountries();

Get a list of regions for all countries.

$cdek = Cdek::getInstance();
$regions = $cdek->getRegions();

Get a list of regions for specified country.

$cdek = Cdek::getInstance();
$regions = $cdek->getRegions(array('countryid' => 1));

Get a list of cities for all countries and regions.

$cdek = Cdek::getInstance();
$cities = $cdek->getCities();

Get a list of cities for specified country.

$cdek = Cdek::getInstance();
$cities = $cdek->getCities(array('countryid' => 1));

Get a list of cities for specified region.

$cdek = Cdek::getInstance();
$cities = $cdek->getCities(array('regionid' => 7));

Calculate delivery rate without authorization.

$cdek = Cdek::getInstance();
$rate = $cdek->calculateDeliveryRate(array(
 'senderCityId' => 44,
 'receiverCityId' => 419,
 'dateExecute' => '2018-07-19',
 'tariffId' => 1,
 'goods' => array(
 array('weight' => 5, 'length' => 10, 'width' => 10, 'height' => 10),
 array('weight' => 3, 'volume' => 0.1),
 ),
));

Calculate delivery rate with authorization.

$cdek = Cdek::getInstance();
$rate = $cdek->calculateDeliveryRate(array(
 'authLogin' => 'YOUR_CDEK_LOGIN',
 'secure' => 'YOUR_CDEK_PASSWORD',
 'senderCityId' => 44,
 'receiverCityId' => 419,
 'dateExecute' => '2018-07-19',
 'tariffId' => 1,
 'goods' => array(
 array('weight' => 5, 'length' => 10, 'width' => 10, 'height' => 10),
 array('weight' => 3, 'volume' => 0.1),
 ),
));

Calculate delivery rate by taking the authorization and other possible parameters from the settings.

$cdek = Cdek::getInstance();
$rate = $cdek->calculateDeliveryRate(array(
 'authLogin' => TRUE,
 'receiverCityId' => 419,
 'goods' => array(
 array('weight' => 5, 'length' => 10, 'width' => 10, 'height' => 10),
 array('weight' => 3, 'volume' => 0.1),
 ),
));

Form element

Basic usage.

$form['point'] = array(
 '#type' => 'cdek_api_select',
 '#title' => 'Order pickup point',
);

Advanced usage.

$form['point'] = array(
 '#type' => 'cdek_api_select',
 '#title' => 'Order pickup point',
 '#default_value' => 'KSD30',
 '#required' => TRUE,
 '#cdek_api_options' => array(
 // Sub-elements can be hidden.
 'hide_country' => TRUE,
 'hide_region' => TRUE,
 'hide_city' => TRUE,
 ),
 '#cdek_api_params' => array(
 // Params for Cdek::getOrderPickupPoints().
 ),
);

Help improve this page

Page status: No known problems

You can: