Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
BeforeLineItemRemovedEvent example
foreach
(
$ids
as
$id
)
{
$lineItem
=
$cart
->
get
(
$id
)
;
if
(
!
$lineItem
)
{
throw
CartException::
lineItemNotFound
(
$id
)
;
}
$lineItems
[
]
=
$lineItem
;
$cart
->
remove
(
$id
)
;
$this
->eventDispatcher->
dispatch
(
new
BeforeLineItemRemovedEvent
(
$lineItem
,
$cart
,
$context
)
)
;
$cart
->
markModified
(
)
;
}
$cart
=
$this
->cartCalculator->
calculate
(
$cart
,
$context
)
;
$this
->cartPersister->
save
(
$cart
,
$context
)
;
$this
->eventDispatcher->
dispatch
(
new
AfterLineItemRemovedEvent
(
$lineItems
,
$cart
,
$context
)
)
;
$this
->eventDispatcher->
dispatch
(
new
CartChangedEvent
(
$cart
,
$context
)
)
;