1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
byweight.php
См. документацию.
1<?php
2namespace Bitrix\Sale\Delivery\Restrictions;
3
4use Bitrix\Main\Localization\Loc;
5use Bitrix\Sale\Internals\Entity;
6use Bitrix\Sale\Shipment;
7
8Loc::loadMessages(__FILE__);
9
15class ByWeight extends Base
16{
17 public static function getClassTitle()
18 {
19 return Loc::getMessage("SALE_DLVR_RSTR_BY_WEIGHT_NAME");
20 }
21
22 public static function getClassDescription()
23 {
24 return Loc::getMessage("SALE_DLVR_RSTR_BY_WEIGHT_DESCRIPT");
25 }
26
27 public static function check($weight, array $restrictionParams, $deliveryId = 0)
28 {
29 if(empty($restrictionParams))
30 return true;
31
32 $weight = floatval($weight);
33
34 if(isset($restrictionParams["MIN_WEIGHT"]) && floatval($restrictionParams["MIN_WEIGHT"]) > 0 && $weight < floatval($restrictionParams["MIN_WEIGHT"]))
35 return false;
36
37 if(isset($restrictionParams["MAX_WEIGHT"]) && floatval($restrictionParams["MAX_WEIGHT"]) > 0 && $weight > floatval($restrictionParams["MAX_WEIGHT"]))
38 return false;
39
40 return true;
41 }
42
43 protected static function extractParams(Entity $entity)
44 {
45 if (!($entity instanceof Shipment))
46 return false;
47
48 return $entity->getWeight();
49 }
50
51 public static function getParamsStructure($entityId = 0)
52 {
53 return array(
54 "MIN_WEIGHT" => array(
55 'TYPE' => 'NUMBER',
56 'DEFAULT' => "0",
57 'MIN' => 0,
58 'LABEL' => Loc::getMessage("SALE_DLVR_RSTR_BY_WEIGHT_MIN_WEIGHT")
59 ),
60 "MAX_WEIGHT" => array(
61 'TYPE' => 'NUMBER',
62 'DEFAULT' => "0",
63 'MIN' => 0,
64 'LABEL' => Loc::getMessage("SALE_DLVR_RSTR_BY_WEIGHT_MAX_WEIGHT")
65 )
66 );
67 }
68}
static extractParams(Entity $entity)
Определения byweight.php:43
static check($weight, array $restrictionParams, $deliveryId=0)
Определения byweight.php:27
static getParamsStructure($entityId=0)
Определения byweight.php:51
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$entity
Определения ufield.php:9
$entityId
Определения payment.php:4