Server IP : 80.87.202.40 / Your IP : 216.73.216.169 Web Server : Apache System : Linux rospirotorg.ru 5.14.0-539.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Dec 5 22:26:13 UTC 2024 x86_64 User : bitrix ( 600) PHP Version : 8.2.27 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /home/bitrix/ext_www/rospirotorg.ru/bitrix/modules/yandex.market/lib/export/delivery/ |
Upload File : |
<?php namespace Yandex\Market\Export\Delivery; use Yandex\Market; class Model extends Market\Reference\Storage\Model { public static function getDataClass() { return Table::class; } public function getDeliveryType() { return $this->getField('DELIVERY_TYPE') ?: Table::DELIVERY_TYPE_DELIVERY; } public function getDeliveryOption() { $result = null; $cost = $this->getCost(); $days = $this->getDays(); if (isset($cost, $days)) { $result = [ 'COST' => $cost, 'DAYS' => $days ]; $orderBefore = $this->getOrderBefore(); if (isset($orderBefore)) { $result['ORDER_BEFORE'] = $orderBefore; } } return $result; } public function getCost() { $value = trim($this->getField('PRICE')); $valueFloat = (float)$value; $result = null; if ($valueFloat >= 0 && $value !== '') { $result = round($valueFloat, 2); } return $result; } public function getDays() { $periodFromValue = trim($this->getField('PERIOD_FROM')); $periodFrom = (int)$periodFromValue; $hasPeriodFrom = ($periodFromValue !== '' && $periodFrom >= 0); $periodToValue = trim($this->getField('PERIOD_TO')); $periodTo = (int)$periodToValue; $hasPeriodTo = ($periodToValue !== '' && $periodTo >= 0); $result = null; if ($hasPeriodFrom && $hasPeriodTo) { if ($periodFrom < $periodTo) { $result = $periodFrom . '-' . $periodTo; } else { $result = $periodFrom; } } else if ($hasPeriodFrom) { $result = $periodFrom; } else if ($hasPeriodTo) { $result = $periodTo; } return $result; } public function getOrderBefore() { $value = trim($this->getField('ORDER_BEFORE')); $valueInt = (int)$value; $result = null; if ($valueInt >= 0 && $valueInt <= 24 && $value !== '') { $result = $valueInt; } return $result; } }