Bitrix-D7 23.9
 
Загрузка...
Поиск...
Не найдено
configuration.php
1<?php
2namespace Bitrix\Sale;
3
10
11Loc::loadMessages(__FILE__);
12
18{
19 private static bool $enableAutomaticReservation;
20
23 const STATUS_ON_PAY = 'R';
24 const STATUS_ON_FULL_PAY = 'P';
25
32 public static function getReservationConditionList($extendedMode = false)
33 {
34 $extendedMode = ($extendedMode === true);
35 if ($extendedMode)
36 {
37 return array(
38 ReserveCondition::ON_CREATE => Loc::getMessage('SALE_CONFIGURATION_RESERVE_ON_CREATE'),
39 ReserveCondition::ON_FULL_PAY => Loc::getMessage('SALE_CONFIGURATION_RESERVE_ON_FULL_PAY'),
40 ReserveCondition::ON_PAY => Loc::getMessage('SALE_CONFIGURATION_RESERVE_ON_PAY'),
41 ReserveCondition::ON_ALLOW_DELIVERY => Loc::getMessage('SALE_CONFIGURATION_RESERVE_ON_ALLOW_DELIVERY'),
42 ReserveCondition::ON_SHIP => Loc::getMessage('SALE_CONFIGURATION_RESERVE_ON_SHIP')
43 );
44 }
45 return array(
46 ReserveCondition::ON_CREATE,
47 ReserveCondition::ON_FULL_PAY,
48 ReserveCondition::ON_PAY,
49 ReserveCondition::ON_ALLOW_DELIVERY,
50 ReserveCondition::ON_SHIP
51 );
52 }
53
59 private static function getReservationSettings(): ReservationSettings
60 {
61 static $settings;
62
63 if (!isset($settings))
64 {
65 $settings = ReservationSettingsService::getInstance()->get();
66 }
67
68 return $settings;
69 }
70
77 public static function getProductReservationCondition()
78 {
79 return self::getReservationSettings()->getReserveCondition();
80 }
81
85 public static function isEnableAutomaticReservation() : bool
86 {
87 if (!isset(self::$enableAutomaticReservation))
88 {
89 self::$enableAutomaticReservation = self::getReservationSettings()->isEnableAutomaticReservation();
90 }
91 return self::$enableAutomaticReservation;
92 }
93
94 public static function enableAutomaticReservation()
95 {
96 self::$enableAutomaticReservation = true;
97 }
98
99 public static function disableAutomaticReservation()
100 {
101 self::$enableAutomaticReservation = false;
102 }
103
110 public static function getProductReserveClearPeriod()
111 {
112 return self::getReservationSettings()->getClearPeriod();
113 }
114
120 public static function isReservationDependsOnShipment()
121 {
122 $condition = static::getProductReservationCondition();
123 return in_array($condition, array(ReserveCondition::ON_SHIP, ReserveCondition::ON_ALLOW_DELIVERY));
124 }
125
131 public static function isCanUse1c(): bool
132 {
133 $lang = LANGUAGE_ID;
134 if (Loader::includeModule('bitrix24'))
135 {
136 $lang = \CBitrix24::getLicensePrefix();
137 }
138 elseif (Loader::includeModule('intranet'))
139 {
140 $lang = \CIntranetUtils::getPortalZone();
141 }
142
143 return in_array($lang, ['ru', 'ua', 'by', 'kz'], true);
144 }
145
151 public static function isAvailableOrdersImportFromB24(): bool
152 {
153 $lang = LANGUAGE_ID;
154 if (Loader::includeModule('bitrix24'))
155 {
156 $lang = \CBitrix24::getLicensePrefix();
157 }
158 elseif (Loader::includeModule('intranet'))
159 {
160 $lang = \CIntranetUtils::getPortalZone();
161 }
162
163 return in_array($lang, ['ru', 'ua', 'by', 'kz'], true);
164 }
165
171 public static function isCanUsePersonalization(): bool
172 {
173 $lang = LANGUAGE_ID;
174 if (Loader::includeModule('bitrix24'))
175 {
176 $lang = \CBitrix24::getLicensePrefix();
177 }
178 elseif (Loader::includeModule('intranet'))
179 {
180 $lang = \CIntranetUtils::getPortalZone();
181 }
182
183 return in_array($lang, ['ru', 'ua', 'by', 'kz'], true);
184 }
185
192 public static function needShipOnAllowDelivery()
193 {
194 $registry = Registry::getInstance(Registry::REGISTRY_TYPE_ORDER);
195 $optionClassName = $registry->get(Registry::ENTITY_OPTIONS);
196
197 return ((string)$optionClassName::get('sale', 'allow_deduction_on_delivery') === 'Y');
198 }
199
206 public static function needAllowDeliveryOnPay()
207 {
208 $condition = static::getAllowDeliveryOnPayCondition();
209 return in_array($condition, array(static::ALLOW_DELIVERY_ON_PAY, ReserveCondition::ON_ALLOW_DELIVERY));
210 }
211
216 public static function getAllowDeliveryOnPayCondition()
217 {
218 $registry = Registry::getInstance(Registry::REGISTRY_TYPE_ORDER);
219 $optionClassName = $registry->get(Registry::ENTITY_OPTIONS);
220
221 return $optionClassName::get('sale', 'status_on_change_allow_delivery_after_paid');
222 }
223
229 public static function getAllowDeliveryAfterPaidConditionList($extendedMode = false)
230 {
231 if ($extendedMode)
232 {
233 return array(
234 self::ALLOW_DELIVERY_ON_PAY => Loc::getMessage('SALE_CONFIGURATION_ON_PAY'),
235 self::ALLOW_DELIVERY_ON_FULL_PAY => Loc::getMessage('SALE_CONFIGURATION_ON_FULL_PAY'),
236 );
237 }
238 return array(
239 self::ALLOW_DELIVERY_ON_PAY,
240 self::ALLOW_DELIVERY_ON_FULL_PAY,
241 );
242 }
243
247 public static function getStatusPaidCondition()
248 {
249 $registry = Registry::getInstance(Registry::REGISTRY_TYPE_ORDER);
250 $optionClassName = $registry->get(Registry::ENTITY_OPTIONS);
251
252 return $optionClassName::get('sale', 'status_on_paid_condition');
253 }
254
258 public static function getStatusAllowDeliveryCondition()
259 {
260 $registry = Registry::getInstance(Registry::REGISTRY_TYPE_ORDER);
261 $optionClassName = $registry->get(Registry::ENTITY_OPTIONS);
262
263 return $optionClassName::get('sale', 'status_on_paid_condition');
264 }
265
271 public static function useStoreControl()
272 {
273 if (!Loader::includeModule('catalog'))
274 return false;
275
276 return Catalog\Config\State::isUsedInventoryManagement();
277 }
278
283 public static function getDefaultStoreId()
284 {
285 if (
286 !Loader::includeModule('catalog')
287 || !self::useStoreControl()
288 )
289 {
290 return 0;
291 }
292
293 return (int)Catalog\StoreTable::getDefaultStoreId();
294 }
295
302 public static function isEnabledReservation()
303 {
304 $registry = Registry::getInstance(Registry::REGISTRY_TYPE_ORDER);
305 $optionClassName = $registry->get(Registry::ENTITY_OPTIONS);
306
307 return ((string)$optionClassName::get('catalog', 'enable_reservation') === 'Y');
308 }
309
315 {
316 $registry = Registry::getInstance(Registry::REGISTRY_TYPE_ORDER);
317 $optionClassName = $registry->get(Registry::ENTITY_OPTIONS);
318
319 return $optionClassName::get('sale', 'discount_separately_calculation') === 'Y';
320 }
321}
static loadMessages($file)
Definition loc.php:64
static getMessage($code, $replace=null, $language=null)
Definition loc.php:29
static isAllowedSeparatelyDiscountCalculation()
static getReservationConditionList($extendedMode=false)
static getAllowDeliveryAfterPaidConditionList($extendedMode=false)