1 | <?php |
||
16 | class RussianPost extends \Ecommerce\DeliveryProvider { |
||
17 | static $name = 'PickPoint - курьерская служба'; |
||
|
|||
18 | |||
19 | static function request($cart) { |
||
20 | $city = ''; |
||
21 | foreach ($cart->deliveryInfos as $deliveryInfo) { |
||
22 | if ($deliveryInfo->field->code == 'index') { |
||
23 | $city = $deliveryInfo->value; |
||
24 | } |
||
25 | } |
||
26 | if (!$city) { |
||
27 | $cityItem = static::getCity($cart); |
||
28 | if ($cityItem) { |
||
29 | $data = json_decode($cityItem->data, true); |
||
30 | if (!empty($data['PostCodeList'])) { |
||
31 | $city = explode(',', $data['PostCodeList'])[0]; |
||
32 | } |
||
33 | } |
||
34 | } |
||
35 | if (!$city) { |
||
36 | return []; |
||
37 | } |
||
38 | $senderCity = '101000'; |
||
39 | |||
40 | $data = [ |
||
41 | 'object' => 4030, |
||
42 | 'weight' => '3000', |
||
43 | 'date' => date('Ymd'), |
||
44 | //'sumoc' => $cart->itemsSum()->sums[0], |
||
45 | 'from' => $senderCity, |
||
46 | 'to' => $city, |
||
47 | 'delivery' => 1, |
||
48 | ]; |
||
49 | $result = \Cache::get('russianPostCalc', $data, function ($data) { |
||
50 | return file_get_contents('http://tariff.russianpost.ru/tariff/v1/calculate?json&' . http_build_query($data)); |
||
51 | }, 4 * 60 * 60); |
||
52 | return json_decode($result, true); |
||
53 | } |
||
54 | |||
55 | static function calcPrice($cart) { |
||
64 | |||
65 | static function deliveryTime($cart) { |
||
85 | |||
86 | static function availablePayTypeGroups($cart) { |
||
89 | } |
The PSR-2 coding standard requires that all properties in a class have their visibility explicitly declared. If you declare a property using
the property is implicitly global.
To learn more about the PSR-2, please see the PHP-FIG site on the PSR-2.