Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
currency.php
1<?php
2
4
15
16Loc::loadMessages(__FILE__);
17
18class Currency extends Base\Restriction
19{
26 public static function check($params, array $restrictionParams, $serviceId = 0)
27 {
28 if (isset($restrictionParams) && is_array($restrictionParams['CURRENCY']))
29 return in_array($params, $restrictionParams['CURRENCY']);
30
31 return true;
32 }
33
39 protected static function extractParams(Entity $entity)
40 {
41 if ($entity instanceof Payment)
42 {
44 $collection = $entity->getCollection();
45
47 $order = $collection->getOrder();
48
49 return $order->getCurrency();
50 }
51 elseif ($entity instanceof Order)
52 {
53 return $entity->getCurrency();
54 }
55
56 throw new ArgumentTypeException('');
57 }
58
62 public static function getClassTitle()
63 {
64 return Loc::getMessage('SALE_PS_RESTRICTIONS_BY_CURRENCY');
65 }
66
70 public static function getClassDescription()
71 {
72 return Loc::getMessage('SALE_PS_RESTRICTIONS_BY_CURRENCY_DESC');
73 }
74
75 public static function getOnApplyErrorMessage(): string
76 {
77 return Loc::getMessage('SALE_PS_RESTRICTIONS_BY_CURRENCY_ON_APPLY_ERROR_MSG');
78 }
79
80 public static function getParamsStructure($entityId = 0)
81 {
82 $data = PaySystem\Manager::getById($entityId);
83
84 $currencyList = CurrencyManager::getCurrencyList();
85
86 if ($data !== false)
87 {
89 $paySystem = new Service($data);
90 $psCurrency = $paySystem->getCurrency();
91
92 $options = array();
93 foreach ($psCurrency as $code)
94 $options[$code] = (isset($currencyList[$code])) ? $currencyList[$code] : $code;
95
96 if ($options)
97 {
98 return array(
99 "CURRENCY" => array(
100 "TYPE" => "ENUM",
101 'MULTIPLE' => 'Y',
102 "LABEL" => Loc::getMessage("SALE_PS_RESTRICTIONS_BY_CURRENCY_NAME"),
103 "OPTIONS" => $options
104 )
105 );
106 }
107 }
108
109 return array();
110 }
111
112 public static function save(array $fields, $restrictionId = 0)
113 {
114 return parent::save($fields, $restrictionId);
115 }
116
117
118}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static extractParams(Entity $entity)
static check($params, array $restrictionParams, $serviceId=0)
Definition currency.php:26
static save(array $fields, $restrictionId=0)
Definition currency.php:112