1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
byprice.php
См. документацию.
1<?php
2namespace Bitrix\Sale\Delivery\Restrictions;
3
4use \Bitrix\Main\Localization\Loc;
5use Bitrix\Sale\Delivery\Restrictions\Base;
6use Bitrix\Sale\Internals\CollectableEntity;
7use Bitrix\Sale\Internals\Entity;
8use Bitrix\Sale\Services\Base\RestrictionManager;
9use Bitrix\Sale\Shipment;
10
11Loc::loadMessages(__FILE__);
12
18class ByPrice extends Base
19{
20 public static function getClassTitle()
21 {
22 return Loc::getMessage("SALE_DLVR_RSTR_BY_PRICE_NAME");
23 }
24
25 public static function getClassDescription()
26 {
27 return Loc::getMessage("SALE_DLVR_RSTR_BY_PRICE_DESCRIPT");
28 }
29
30 public static function check($price, array $restrictionParams, $deliveryId = 0)
31 {
32 if(empty($restrictionParams))
33 return true;
34
35 if($price < 0)
36 return true;
37
38 $price = floatval($price);
39
40 if(floatval($restrictionParams["MIN_PRICE"]) > 0 && $price < floatval($restrictionParams["MIN_PRICE"]))
41 $result = false;
42 elseif(floatval($restrictionParams["MAX_PRICE"]) > 0 && $price > floatval($restrictionParams["MAX_PRICE"]))
43 $result = false;
44 else
45 $result = true;
46
47 return $result;
48 }
49
50
51 public static function checkByEntity(Entity $shipment, array $restrictionParams, $mode, $deliveryId = 0)
52 {
53 $severity = self::getSeverity($mode);
54
55 if($severity == RestrictionManager::SEVERITY_NONE)
56 return RestrictionManager::SEVERITY_NONE;
57
58 $price = self::extractParams($shipment);
59 $sCurrency = $shipment->getCurrency();
60
61 if (!empty($sCurrency) && !empty($restrictionParams["CURRENCY"]) && \Bitrix\Main\Loader::includeModule('currency'))
62 {
63 $price = \CCurrencyRates::convertCurrency(
64 $price,
65 $sCurrency,
66 $restrictionParams["CURRENCY"]
67 );
68 }
69
70 $res = self::check($price, $restrictionParams, $deliveryId);
71 return $res ? RestrictionManager::SEVERITY_NONE : $severity;
72 }
73
74 protected static function extractParams(Entity $entity)
75 {
76 if ($entity instanceof Shipment)
77 {
78 if(!$itemCollection = $entity->getShipmentItemCollection())
79 return -1;
80 }
81 else
82 {
83 return -1;
84 }
85
86 return $itemCollection->getPrice();
87 }
88
89 public static function getParamsStructure($entityId = 0)
90 {
91 return array(
92 "MIN_PRICE" => array(
93 "TYPE" => "NUMBER",
94 "DEFAULT" => "0",
95 'MIN' => 0,
96 "LABEL" => Loc::getMessage("SALE_DLVR_RSTR_BY_PRICE_MIN_PRICE")
97 ),
98
99 "MAX_PRICE" => array(
100 "TYPE" => "NUMBER",
101 "DEFAULT" => "0",
102 'MIN' => 0,
103 "LABEL" => Loc::getMessage("SALE_DLVR_RSTR_BY_PRICE_MAX_PRICE")
104 ),
105
106 "CURRENCY" => array(
107 "TYPE" => "ENUM",
108 "DEFAULT" => "RUB",
109 "LABEL" => Loc::getMessage("SALE_DLVR_RSTR_BY_PRICE_CURRECY"),
110 "OPTIONS" => \Bitrix\Sale\Delivery\Helper::getCurrenciesList()
111 )
112 );
113 }
114}
static extractParams(Entity $entity)
Определения byprice.php:74
static check($price, array $restrictionParams, $deliveryId=0)
Определения byprice.php:30
static checkByEntity(Entity $shipment, array $restrictionParams, $mode, $deliveryId=0)
Определения byprice.php:51
static getClassDescription()
Определения byprice.php:25
static getParamsStructure($entityId=0)
Определения byprice.php:89
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения file_new.php:804
$res
Определения filter_act.php:7
$result
Определения get_property_values.php:14
$entity
Определения ufield.php:9
$entityId
Определения payment.php:4
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393