You are a developer and looking for Shopware projects?
Apply Now!
createFromLineItem example
return
$this
->
calculateLineItems
(
$lineItems
,
$context
,
$behavior
)
;
}
private
function
calculateLineItems
(
LineItemCollection
$lineItems
, SalesChannelContext
$context
, CartBehavior
$behavior
)
: LineItemCollection
{
$workingSet
=
clone
$lineItems
;
$workingSet
->
sortByPriority
(
)
;
$calculated
=
new
LineItemCollection
(
)
;
foreach
(
$workingSet
as
$original
)
{
$lineItem
= LineItem::
createFromLineItem
(
$original
)
;
$price
=
$this
->
calculatePrice
(
$lineItem
,
$context
,
$calculated
,
$behavior
)
;
$lineItem
->
setPrice
(
$price
)
;
$calculated
->
add
(
$lineItem
)
;
}
return
$calculated
;
}