Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
AfterLineItemAddedEvent example
$alreadyExists
=
$cart
->
has
(
$item
->
getId
(
)
)
;
$cart
->
add
(
$item
)
;
$this
->eventDispatcher->
dispatch
(
new
BeforeLineItemAddedEvent
(
$item
,
$cart
,
$context
,
$alreadyExists
)
)
;
}
$cart
->
markModified
(
)
;
$cart
=
$this
->cartCalculator->
calculate
(
$cart
,
$context
)
;
$this
->cartPersister->
save
(
$cart
,
$context
)
;
$this
->eventDispatcher->
dispatch
(
new
AfterLineItemAddedEvent
(
$items
,
$cart
,
$context
)
)
;
$this
->eventDispatcher->
dispatch
(
new
CartChangedEvent
(
$cart
,
$context
)
)
;
return
new
CartResponse
(
$cart
)
;
}
}