Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
checkbox.php
1
<?php
2
3
namespace
Bitrix\Sale\Delivery\ExtraServices
;
4
5
use
Bitrix\Main\SystemException
;
6
use
Bitrix\Main\Localization\Loc
;
7
8
Loc::loadMessages
(__FILE__);
9
10
class
Checkbox
extends
Base
11
{
12
public
function
__construct
($id, array $structure, $currency, $value =
null
, array $additionalParams = array())
13
{
14
$structure[
"PARAMS"
][
"ONCHANGE"
] = $this->
createJSOnchange
($id, $structure[
"PARAMS"
][
"PRICE"
] ?? 0);
15
parent::__construct($id, $structure, $currency, $value, $additionalParams);
16
$this->params[
"TYPE"
] =
"Y/N"
;
17
}
18
19
public
static
function
getClassTitle
()
20
{
21
return
Loc::getMessage
(
"DELIVERY_EXTRA_SERVICE_CHECKBOX_TITLE"
);
22
}
23
24
public
function
getCost
()
25
{
26
return
27
$this->value ===
'Y'
28
? (float)$this->getPrice()
29
: 0
30
;
31
}
32
33
public
static
function
getAdminParamsName
()
34
{
35
return
Loc::getMessage
(
"DELIVERY_EXTRA_SERVICE_CHECKBOX_PRICE"
);
36
}
37
38
public
static
function
prepareParamsToSave
(array $params): array
39
{
40
$params[
'PARAMS'
][
'PRICE'
] ??= 0.0;
41
$params[
'PARAMS'
][
'PRICE'
] = (float)$params[
'PARAMS'
][
'PRICE'
];
42
43
return
$params;
44
}
45
public
static
function
getAdminParamsControl
($name, array $params, $currency =
""
)
46
{
47
$currency = (string)$currency;
48
49
return
50
\Bitrix\Sale\Internals\Input\Manager::getEditHtml(
51
$name.
"[PARAMS][PRICE]"
,
52
[
53
"TYPE"
=>
"NUMBER"
54
],
55
$params[
"PARAMS"
][
"PRICE"
] ?? 0
56
)
57
. ($currency !==
''
?
' ('
. $currency .
')'
:
''
)
58
;
59
}
60
61
public
function
setOperatingCurrency
($currency)
62
{
63
$this->params[
"ONCHANGE"
] = $this->
createJSOnchange
($this->
id
, $this->getPrice());
64
parent::setOperatingCurrency($currency);
65
}
66
67
protected
function
createJSOnchange
($id, $price)
68
{
69
$price = roundEx(floatval($price), SALE_VALUE_PRECISION);
70
return
"BX.onCustomEvent('onDeliveryExtraServiceValueChange', [{'id' : '"
.$id.
"', 'value': this.checked, 'price': this.checked ? '"
.$price.
"' : '0'}]);"
;
71
}
72
76
public
function
getDisplayValue
(): ?string
77
{
78
if
($this->value ===
'Y'
)
79
{
80
return
Loc::getMessage
(
'DELIVERY_EXTRA_SERVICE_CHECKBOX_YES'
);
81
}
82
83
if
($this->value ===
'N'
)
84
{
85
return
Loc::getMessage
(
'DELIVERY_EXTRA_SERVICE_CHECKBOX_NO'
);
86
}
87
88
return
null
;
89
}
90
}
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\Main\SystemException
Definition
exception.php:8
Bitrix\Sale\Delivery\ExtraServices\Base
Definition
base.php:10
Bitrix\Sale\Delivery\ExtraServices\Checkbox
Definition
checkbox.php:11
Bitrix\Sale\Delivery\ExtraServices\Checkbox\getDisplayValue
getDisplayValue()
Definition
checkbox.php:76
Bitrix\Sale\Delivery\ExtraServices\Checkbox\__construct
__construct($id, array $structure, $currency, $value=null, array $additionalParams=array())
Definition
checkbox.php:12
Bitrix\Sale\Delivery\ExtraServices\Checkbox\setOperatingCurrency
setOperatingCurrency($currency)
Definition
checkbox.php:61
Bitrix\Sale\Delivery\ExtraServices\Checkbox\createJSOnchange
createJSOnchange($id, $price)
Definition
checkbox.php:67
Bitrix\Sale\Delivery\ExtraServices\Checkbox\getCost
getCost()
Definition
checkbox.php:24
Bitrix\Sale\Delivery\ExtraServices\Checkbox\getClassTitle
static getClassTitle()
Definition
checkbox.php:19
Bitrix\Sale\Delivery\ExtraServices\Checkbox\getAdminParamsControl
static getAdminParamsControl($name, array $params, $currency="")
Definition
checkbox.php:45
Bitrix\Sale\Delivery\ExtraServices\Checkbox\getAdminParamsName
static getAdminParamsName()
Definition
checkbox.php:33
Bitrix\Sale\Delivery\ExtraServices\Checkbox\prepareParamsToSave
static prepareParamsToSave(array $params)
Definition
checkbox.php:38
Bitrix\Sale\Delivery\ExtraServices
Definition
base.php:3
modules
sale
lib
delivery
extra_services
checkbox.php
Создано системой
1.10.0