Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
emptydeliveryservice.php
1
<?php
2
3
namespace
Bitrix\Sale\Delivery\Services
;
4
5
use
Bitrix\Main\Application
;
6
use
Bitrix\Main\Localization\Loc
;
7
use
Bitrix\Currency
;
8
use
Bitrix\Sale\Internals\ServiceRestrictionTable
;
9
10
Loc::loadMessages
(__FILE__);
11
17
class
EmptyDeliveryService
extends
Configurable
18
{
20
protected
$handlerCode
=
'BITRIX_EMPTY'
;
21
22
const
CACHE_ID
=
'BITRIX_SALE_EMPTY_DELIVERY_SRV_ID'
;
23
const
TTL
= 31536000;
24
28
public
static
function
getClassTitle
()
29
{
30
return
Loc::getMessage
(
'SALE_DLVR_HANDL_EMP_DLV_SRV_TITLE'
);
31
}
32
36
public
static
function
getClassDescription
()
37
{
38
return
Loc::getMessage
(
'SALE_DLVR_HANDL_EMP_DLV_SRV_DESC'
);
39
}
40
45
public
static
function
getEmptyDeliveryServiceId
()
46
{
47
$id = 0;
48
$cacheManager =
Application::getInstance
()->getManagedCache();
49
50
if
($cacheManager->read(self::TTL, self::CACHE_ID))
51
$id = $cacheManager->get(self::CACHE_ID);
52
53
if
($id <= 0)
54
{
55
$data = Table::getRow(
56
array(
57
'select'
=> array(
'ID'
),
58
'filter'
=> array(
'=CLASS_NAME'
=>
'\Bitrix\Sale\Delivery\Services\EmptyDeliveryService'
)
59
)
60
);
61
if
($data !==
null
)
62
$id = $data[
'ID'
];
63
else
64
$id = self::create();
65
66
if
($id > 0)
67
$cacheManager->set(self::CACHE_ID, $id);
68
}
69
70
return
(
int
)$id;
71
}
72
76
private
static
function
create()
77
{
78
$fields[
"NAME"
] =
Loc::getMessage
(
'SALE_DLVR_HANDL_EMP_DLV_SRV_TITLE'
);
79
$fields[
"CLASS_NAME"
] =
'\Bitrix\Sale\Delivery\Services\EmptyDeliveryService'
;
80
$fields[
"PARENT_ID"
] = 0;
81
$fields[
"CURRENCY"
] = Currency\CurrencyManager::getBaseCurrency();
82
$fields[
"ACTIVE"
] =
"Y"
;
83
$fields[
"CONFIG"
] = array(
'MAIN'
=> array(
'CURRENCY'
=> Currency\CurrencyManager::getBaseCurrency(),
'PRICE'
=> 0,
'PERIOD'
=> array(
'FROM'
=> 0,
'TO'
=> 0,
'TYPE'
=>
'D'
)));
84
$fields[
"SORT"
] = 100;
85
86
$res = Table::add($fields);
87
88
if
(!$res->isSuccess())
89
return
0;
90
91
ServiceRestrictionTable::add(array(
'SORT'
=> 100,
'SERVICE_ID'
=> $res->getId(),
'PARAMS'
=> array(
'PUBLIC_SHOW'
=>
'N'
),
'SERVICE_TYPE'
=>
'0'
,
'CLASS_NAME'
=>
'\Bitrix\Sale\Delivery\Restrictions\ByPublicMode'
));
92
93
return
$res->getId();
94
}
95
96
public
static
function
isHandlerCompatible
()
97
{
98
return
true
;
99
}
100
}
Bitrix\Main\Application
Definition
application.php:28
Bitrix\Main\Application\getInstance
static getInstance()
Definition
application.php:95
Bitrix\Main\Localization\Loc
Definition
loc.php:11
Bitrix\Main\Localization\Loc\loadMessages
static loadMessages($file)
Definition
loc.php:64
Bitrix\Main\Localization\Loc\getMessage
static getMessage($code, $replace=null, $language=null)
Definition
loc.php:29
Bitrix\Sale\Delivery\Services\Configurable
Definition
configurable.php:20
Bitrix\Sale\Delivery\Services\EmptyDeliveryService
Definition
emptydeliveryservice.php:18
Bitrix\Sale\Delivery\Services\EmptyDeliveryService\CACHE_ID
const CACHE_ID
Definition
emptydeliveryservice.php:22
Bitrix\Sale\Delivery\Services\EmptyDeliveryService\getEmptyDeliveryServiceId
static getEmptyDeliveryServiceId()
Definition
emptydeliveryservice.php:45
Bitrix\Sale\Delivery\Services\EmptyDeliveryService\TTL
const TTL
Definition
emptydeliveryservice.php:23
Bitrix\Sale\Delivery\Services\EmptyDeliveryService\getClassTitle
static getClassTitle()
Definition
emptydeliveryservice.php:28
Bitrix\Sale\Delivery\Services\EmptyDeliveryService\getClassDescription
static getClassDescription()
Definition
emptydeliveryservice.php:36
Bitrix\Sale\Delivery\Services\EmptyDeliveryService\isHandlerCompatible
static isHandlerCompatible()
Definition
emptydeliveryservice.php:96
Bitrix\Sale\Delivery\Services\EmptyDeliveryService\$handlerCode
$handlerCode
Definition
emptydeliveryservice.php:20
Bitrix\Sale\Internals\ServiceRestrictionTable
Definition
servicerestriction.php:39
Bitrix\Currency
Bitrix\Sale\Delivery\Services
Definition
automatic.php:3
modules
sale
lib
delivery
services
emptydeliveryservice.php
Создано системой
1.10.0