01.
public
function
subscribeEvents()
02.
{
03.
Backend::
$events
->addEvent(
'shop:onGetProductPriceNoTax'
,
$this
,
'fix_price'
);
04.
}
05.
06.
public
function
fix_price(
$data
)
07.
{
08.
09.
if
(
$data
[
'customer_group_id'
] == 1)
10.
{
11.
$data
[
'price'
] =
$data
[
'price'
] * 1.1;
12.
return
$data
;
13.
}
14.
15.
16.
if
(
$data
[
'product'
]->sku ==
'testproduct'
)
17.
{
18.
$data
[
'price'
] = 200;
19.
return
$data
;
20.
}
21.
22.
23.
if
(
$data
[
'quantity'
] > 1)
24.
{
25.
if
(
$data
[
'quantity'
] >= 5)
26.
$discount
= 0.5;
27.
else
28.
$discount
=
$data
[
'quantity'
] * 0.1;
29.
30.
$data
[
'price'
] =
$data
[
'price'
] * (1 -
$discount
);
31.
return
$data
;
32.
}
33.
}