1C-Bitrix
25.700.0
Загрузка...
Поиск...
Не найдено
configurable.php
См. документацию.
1
<?php
2
3
namespace
Bitrix\Sale\Delivery\Services;
4
5
use Bitrix\Main\Loader;
6
use Bitrix\Main\SystemException;
7
use Bitrix\Main\Localization\Loc;
8
use Bitrix\Sale\Delivery\CalculationResult;
9
use Bitrix\Currency;
10
11
Loc::loadMessages(__FILE__);
12
19
class
Configurable
extends
Base
20
{
22
protected
$handlerCode
=
'BITRIX_CONFIGURABLE'
;
23
24
protected
static
$isCalculatePriceImmediately
=
true
;
25
protected
static
$whetherAdminExtraServicesShow
=
true
;
26
32
public
function
__construct
(
array
$initParams)
33
{
34
parent::__construct($initParams);
35
36
if
(!isset($this->config[
"MAIN"
][
"PRICE"
]))
37
$this->config[
"MAIN"
][
"PRICE"
] =
"0"
;
38
39
if
(!isset($initParams[
"CURRENCY"
]))
40
$initParams[
"CURRENCY"
] =
"RUB"
;
41
42
if
(!isset($this->config[
"MAIN"
][
"PERIOD"
]) || !is_array($this->config[
"MAIN"
][
"PERIOD"
]))
43
{
44
$this->config[
"MAIN"
][
"PERIOD"
] =
array
();
45
$this->config[
"MAIN"
][
"PERIOD"
][
"FROM"
] =
"0"
;
46
$this->config[
"MAIN"
][
"PERIOD"
][
"TO"
] =
"0"
;
47
$this->config[
"MAIN"
][
"PERIOD"
][
"TYPE"
] =
"D"
;
48
}
49
}
50
54
public
static
function
getClassTitle
()
55
{
56
return
Loc::getMessage(
"SALE_DLVR_HANDL_NAME"
);
57
}
58
62
public
static
function
getClassDescription
()
63
{
64
return
Loc::getMessage(
"SALE_DLVR_HANDL_DESCRIPTION"
);
65
}
66
70
protected
function
getPeriodText
()
71
{
72
$result
=
""
;
73
74
if
(intval($this->config[
"MAIN"
][
"PERIOD"
][
"FROM"
]) > 0 || intval($this->config[
"MAIN"
][
"PERIOD"
][
"TO"
]) > 0)
75
{
76
$result
=
""
;
77
78
if
(intval($this->config[
"MAIN"
][
"PERIOD"
][
"FROM"
]) > 0)
79
$result
.=
" "
.Loc::getMessage(
"SALE_DLVR_HANDL_CONF_PERIOD_FROM"
).
" "
.intval($this->config[
"MAIN"
][
"PERIOD"
][
"FROM"
]);
80
81
if
(intval($this->config[
"MAIN"
][
"PERIOD"
][
"TO"
]) > 0)
82
$result
.=
" "
.Loc::getMessage(
"SALE_DLVR_HANDL_CONF_PERIOD_TO"
).
" "
.intval($this->config[
"MAIN"
][
"PERIOD"
][
"TO"
]);
83
84
if
($this->config[
"MAIN"
][
"PERIOD"
][
"TYPE"
] ==
"MIN"
)
85
$result
.=
" "
.Loc::getMessage(
"SALE_DLVR_HANDL_CONF_PERIOD_MIN"
).
" "
;
86
elseif
($this->config[
"MAIN"
][
"PERIOD"
][
"TYPE"
] ==
"H"
)
87
$result
.=
" "
.Loc::getMessage(
"SALE_DLVR_HANDL_CONF_PERIOD_HOUR"
).
" "
;
88
elseif
($this->config[
"MAIN"
][
"PERIOD"
][
"TYPE"
] ==
"M"
)
89
$result
.=
" "
.Loc::getMessage(
"SALE_DLVR_HANDL_CONF_PERIOD_MONTH"
).
" "
;
90
else
91
$result
.=
" "
.Loc::getMessage(
"SALE_DLVR_HANDL_CONF_PERIOD_DAY"
).
" "
;
92
}
93
94
return
$result
;
95
}
96
97
protected
function
calculateConcrete
(\
Bitrix
\
Sale
\
Shipment
$shipment =
null
)
98
{
99
$result
=
new
CalculationResult
;
100
$price = $this->config[
"MAIN"
][
"PRICE"
];
101
102
if
($shipment && \
Bitrix
\
Main
\Loader::includeModule(
'currency'
))
103
{
104
$rates = new \CCurrencyRates;
105
$currency
=
$this->currency
;
106
$shipmentCurrency = $shipment->getCollection()->getOrder()->getCurrency();
107
$price = $rates->convertCurrency( $price,
$currency
, $shipmentCurrency);
108
}
109
110
$result
->setDeliveryPrice(
111
roundEx
(
112
$price,
113
SALE_VALUE_PRECISION
114
)
115
);
116
117
$result
->setPeriodDescription($this->
getPeriodText
());
118
$result
->setPeriodFrom($this->config[
"MAIN"
][
"PERIOD"
][
"FROM"
]);
119
$result
->setPeriodTo($this->config[
"MAIN"
][
"PERIOD"
][
"TO"
]);
120
$result
->setPeriodType($this->config[
"MAIN"
][
"PERIOD"
][
"TYPE"
]);
121
122
return
$result
;
123
}
124
129
protected
function
getConfigStructure
()
130
{
131
$currency
=
$this->currency
;
132
133
if
(Loader::includeModule(
'currency'
))
134
{
135
$currencyList =
Currency\CurrencyManager::getCurrencyList
();
136
if
(isset($currencyList[$this->currency]))
137
$currency
= $currencyList[
$this->currency
];
138
unset($currencyList);
139
}
140
141
return
array
(
142
143
"MAIN"
=>
array
(
144
"TITLE"
=> Loc::getMessage(
"SALE_DLVR_HANDL_CONF_TITLE"
),
145
"DESCRIPTION"
=> Loc::getMessage(
"SALE_DLVR_HANDL_CONF_DESCRIPTION"
),
146
"ITEMS"
=>
array
(
147
148
"CURRENCY"
=>
array
(
149
"TYPE"
=>
"DELIVERY_READ_ONLY"
,
150
"NAME"
=> Loc::getMessage(
"SALE_DLVR_HANDL_CONF_CURRENCY"
),
151
"VALUE"
=> $this->currency,
152
"VALUE_VIEW"
=>
htmlspecialcharsbx
(
$currency
)
153
),
154
155
"PRICE"
=>
array
(
156
"TYPE"
=>
"NUMBER"
,
157
"MIN"
=> 0,
158
"NAME"
=> Loc::getMessage(
"SALE_DLVR_HANDL_CONF_PRICE"
)
159
),
160
161
"PERIOD"
=>
array
(
162
"TYPE"
=>
"DELIVERY_PERIOD"
,
163
"NAME"
=> Loc::getMessage(
"SALE_DLVR_HANDL_CONF_PERIOD_DLV"
),
164
"ITEMS"
=>
array
(
165
"FROM"
=>
array
(
166
"TYPE"
=>
"NUMBER"
,
167
"MIN"
=> 0,
168
"NAME"
=>
""
//Loc::getMessage("SALE_DLVR_HANDL_CONF_PERIOD_FROM"),
169
),
170
"TO"
=>
array
(
171
"TYPE"
=>
"NUMBER"
,
172
"MIN"
=> 0,
173
"NAME"
=>
" - "
//Loc::getMessage("SALE_DLVR_HANDL_CONF_PERIOD_TO"),
174
),
175
"TYPE"
=>
array
(
176
"TYPE"
=>
"ENUM"
,
177
"OPTIONS"
=>
array
(
178
"MIN"
=> Loc::getMessage(
"SALE_DLVR_HANDL_CONF_PERIOD_MIN"
),
179
"H"
=> Loc::getMessage(
"SALE_DLVR_HANDL_CONF_PERIOD_HOUR"
),
180
"D"
=> Loc::getMessage(
"SALE_DLVR_HANDL_CONF_PERIOD_DAY"
),
181
"M"
=> Loc::getMessage(
"SALE_DLVR_HANDL_CONF_PERIOD_MONTH"
)
182
)
183
)
184
)
185
)
186
)
187
)
188
);
189
}
190
191
public
static
function
getAdminFieldsList
()
192
{
193
$result
= parent::getAdminFieldsList();
194
$result
[
"STORES"
] =
true
;
195
return
$result
;
196
}
197
198
public
function
prepareFieldsForSaving
(
array
$fields
)
199
{
200
if
((!isset(
$fields
[
"CODE"
]) || intval(
$fields
[
"CODE"
]) < 0) && isset(
$fields
[
"ID"
]) && intval(
$fields
[
"ID"
]) > 0)
201
$fields
[
"CODE"
] =
$fields
[
"ID"
];
202
203
return
parent::prepareFieldsForSaving(
$fields
);
204
}
205
206
public
static
function
onAfterAdd
($serviceId,
array
$fields
=
array
())
207
{
208
if
($serviceId <= 0)
209
return
false
;
210
211
$res
=
Manager::update
($serviceId,
array
(
'CODE'
=> $serviceId));
212
return
$res
->isSuccess();
213
}
214
215
public
function
isCalculatePriceImmediately
()
216
{
217
return
self::$isCalculatePriceImmediately;
218
}
219
220
public
static
function
whetherAdminExtraServicesShow
()
221
{
222
return
self::$whetherAdminExtraServicesShow;
223
}
224
225
public
static
function
isHandlerCompatible
()
226
{
227
return
true
;
228
}
229
}
Bitrix\Currency\CurrencyManager\getCurrencyList
static getCurrencyList()
Определения
currencymanager.php:109
Bitrix\Sale\Delivery\CalculationResult
Определения
calculationresult.php:12
Bitrix\Sale\Delivery\Services\Configurable
Определения
configurable.php:20
Bitrix\Sale\Delivery\Services\Configurable\getPeriodText
getPeriodText()
Определения
configurable.php:70
Bitrix\Sale\Delivery\Services\Configurable\getClassTitle
static getClassTitle()
Определения
configurable.php:54
Bitrix\Sale\Delivery\Services\Configurable\calculateConcrete
calculateConcrete(\Bitrix\Sale\Shipment $shipment=null)
Определения
configurable.php:97
Bitrix\Sale\Delivery\Services\Configurable\whetherAdminExtraServicesShow
static whetherAdminExtraServicesShow()
Определения
configurable.php:220
Bitrix\Sale\Delivery\Services\Configurable\$isCalculatePriceImmediately
static $isCalculatePriceImmediately
Определения
configurable.php:24
Bitrix\Sale\Delivery\Services\Configurable\getClassDescription
static getClassDescription()
Определения
configurable.php:62
Bitrix\Sale\Delivery\Services\Configurable\getAdminFieldsList
static getAdminFieldsList()
Определения
configurable.php:191
Bitrix\Sale\Delivery\Services\Configurable\__construct
__construct(array $initParams)
Определения
configurable.php:32
Bitrix\Sale\Delivery\Services\Configurable\prepareFieldsForSaving
prepareFieldsForSaving(array $fields)
Определения
configurable.php:198
Bitrix\Sale\Delivery\Services\Configurable\$whetherAdminExtraServicesShow
static $whetherAdminExtraServicesShow
Определения
configurable.php:25
Bitrix\Sale\Delivery\Services\Configurable\getConfigStructure
getConfigStructure()
Определения
configurable.php:129
Bitrix\Sale\Delivery\Services\Configurable\onAfterAdd
static onAfterAdd($serviceId, array $fields=array())
Определения
configurable.php:206
Bitrix\Sale\Delivery\Services\Configurable\isHandlerCompatible
static isHandlerCompatible()
Определения
configurable.php:225
Bitrix\Sale\Delivery\Services\Configurable\$handlerCode
$handlerCode
Определения
configurable.php:22
Bitrix\Sale\Delivery\Services\Configurable\isCalculatePriceImmediately
isCalculatePriceImmediately()
Определения
configurable.php:215
Bitrix\Sale\Delivery\Services\Manager\update
static update($id, array $fields)
Определения
manager.php:817
Bitrix\Sale\Shipment
Определения
shipment.php:21
array
</td ></tr ></table ></td ></tr >< tr >< td class="bx-popup-label bx-width30"><?=GetMessage("PAGE_NEW_TAGS")?> array( $site)
Определения
file_new.php:804
$res
$res
Определения
filter_act.php:7
$result
$result
Определения
get_property_values.php:14
roundEx
roundEx($value, $prec=0)
Определения
tools.php:4635
htmlspecialcharsbx
htmlspecialcharsbx($string, $flags=ENT_COMPAT, $doubleEncode=true)
Определения
tools.php:2701
Bitrix\Main
Bitrix\Sale\Services\Base
Определения
concreteproductrestriction.php:3
Bitrix\Sale
Bitrix
elseif
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения
prolog_main_admin.php:393
$currency
$currency
Определения
template.php:266
SALE_VALUE_PRECISION
const SALE_VALUE_PRECISION
Определения
include.php:46
$fields
$fields
Определения
yandex_run.php:501
bitrix
modules
sale
lib
delivery
services
configurable.php
Создано системой
1.14.0