Bitrix-D7
23.9
Загрузка...
Поиск...
Не найдено
quantity.php
1
<?php
2
3
namespace
Bitrix\Sale\Delivery\ExtraServices
;
4
5
use
Bitrix\Main\Localization\Loc
;
6
7
Loc::loadMessages
(__FILE__);
8
9
class
Quantity
extends
Base
10
{
11
public
function
__construct
($id, array $structure, $currency, $value =
null
, array $additionalParams = array())
12
{
13
if
(isset($structure[
"PARAMS"
][
"PRICE"
]))
14
$structure[
"PARAMS"
][
"ONCHANGE"
] = $this->
createJSOnchange
($id, $structure[
"PARAMS"
][
"PRICE"
]);
15
16
parent::__construct($id, $structure, $currency, $value);
17
$this->params[
"TYPE"
] =
"STRING"
;
18
}
19
20
public
static
function
getClassTitle
()
21
{
22
return
Loc::getMessage
(
"DELIVERY_EXTRA_SERVICE_QUANTITY_TITLE"
);
23
}
24
25
public
function
setValue
($value)
26
{
27
$this->value = intval($value) >= 0 ? intval($value) : 0;
28
}
29
30
public
function
getCost
()
31
{
32
return
floatval($this->getPrice())*floatval($this->value);
33
}
34
35
public
static
function
getAdminParamsName
()
36
{
37
return
Loc::getMessage
(
"DELIVERY_EXTRA_SERVICE_QUANTITY_PRICE"
);
38
}
39
40
public
static
function
getAdminParamsControl
($name, array $params = array(), $currency =
""
)
41
{
42
if
(!empty($params[
"PARAMS"
][
"PRICE"
]))
43
$price = roundEx(floatval($params[
"PARAMS"
][
"PRICE"
]), SALE_VALUE_PRECISION);
44
else
45
$price = 0;
46
47
return
'<input type="text" name="'
.$name.
'[PARAMS][PRICE]" value="'
.$price.
'">'
.($currency <>
''
?
" ("
.htmlspecialcharsbx($currency).
")"
:
""
);
48
}
49
50
public
function
setOperatingCurrency
($currency)
51
{
52
$this->params[
"ONCHANGE"
] = $this->
createJSOnchange
($this->
id
, $this->getPrice());
53
parent::setOperatingCurrency($currency);
54
}
55
56
protected
function
createJSOnchange
($id, $price)
57
{
58
$price = roundEx(floatval($price), SALE_VALUE_PRECISION);
59
return
"BX.onCustomEvent('onDeliveryExtraServiceValueChange', [{'id' : '"
.$id.
"', 'value': this.value, 'price': this.value*parseFloat('"
.$price.
"')}]);"
;
60
}
61
}
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\ExtraServices\Base
Definition
base.php:10
Bitrix\Sale\Delivery\ExtraServices\Quantity
Definition
quantity.php:10
Bitrix\Sale\Delivery\ExtraServices\Quantity\__construct
__construct($id, array $structure, $currency, $value=null, array $additionalParams=array())
Definition
quantity.php:11
Bitrix\Sale\Delivery\ExtraServices\Quantity\setOperatingCurrency
setOperatingCurrency($currency)
Definition
quantity.php:50
Bitrix\Sale\Delivery\ExtraServices\Quantity\createJSOnchange
createJSOnchange($id, $price)
Definition
quantity.php:56
Bitrix\Sale\Delivery\ExtraServices\Quantity\getCost
getCost()
Definition
quantity.php:30
Bitrix\Sale\Delivery\ExtraServices\Quantity\getClassTitle
static getClassTitle()
Definition
quantity.php:20
Bitrix\Sale\Delivery\ExtraServices\Quantity\setValue
setValue($value)
Definition
quantity.php:25
Bitrix\Sale\Delivery\ExtraServices\Quantity\getAdminParamsControl
static getAdminParamsControl($name, array $params=array(), $currency="")
Definition
quantity.php:40
Bitrix\Sale\Delivery\ExtraServices\Quantity\getAdminParamsName
static getAdminParamsName()
Definition
quantity.php:35
Bitrix\Sale\Delivery\ExtraServices
Definition
base.php:3
modules
sale
lib
delivery
extra_services
quantity.php
Создано системой
1.10.0