Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
byweight.php
1<?php
3
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 loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static check($weight, array $restrictionParams, $deliveryId=0)
Definition byweight.php:27