Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
calculatePriceStruct example
ShopContextInterface
$context
)
{
$tax
=
$context
->
getTaxRule
(
$product
->
getTax
(
)
->
getId
(
)
)
;
if
(
!
$tax
instanceof Tax
)
{
throw
new
StructNotFoundException
(
Tax::
class
,
$product
->
getTax
(
)
->
getId
(
)
)
;
}
$rules
=
$product
->
getPriceRules
(
)
;
$prices
=
[
]
;
foreach
(
$rules
as
$rule
)
{
$prices
[
]
=
$this
->
calculatePriceStruct
(
$rule
,
$tax
,
$context
)
;
}
$product
->
setPrices
(
$prices
)
;
$rules
=
$product
->
getPriceRules
(
)
;
if
(
!
$product
->
getCheapestPriceRule
(
)
&& !
empty
(
$rules
)
)
{
$product
->
setCheapestPriceRule
(
clone
$rules
[
0
]
)
;
}
if
(
$product
->
getCheapestPriceRule
(
)
)
{
/** * Calculation with considering min purchase */