Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
recalculateCart example
public
function
recalculateOrder
(
string
$orderId
, Context
$context
)
: void
{
$order
=
$this
->
fetchOrder
(
$orderId
,
$context
)
;
$this
->
validateOrder
(
$order
,
$orderId
)
;
\
assert
(
$order
instanceof OrderEntity
)
;
$salesChannelContext
=
$this
->orderConverter->
assembleSalesChannelContext
(
$order
,
$context
)
;
$cart
=
$this
->orderConverter->
convertToCart
(
$order
,
$context
)
;
$recalculatedCart
=
$this
->
recalculateCart
(
$cart
,
$salesChannelContext
)
;
$conversionContext
=
(
new
OrderConversionContext
(
)
)
->
setIncludeCustomer
(
false
)
->
setIncludeBillingAddress
(
false
)
->
setIncludeDeliveries
(
true
)
->
setIncludeTransactions
(
false
)
->
setIncludeOrderDate
(
false
)
;
$orderData
=
$this
->orderConverter->
convertToOrder
(
$recalculatedCart
,
$salesChannelContext
,
$conversionContext
)
;
$orderData
[
'id'
]
=
$order
->
getId
(
)
;
$orderData
[
'stateId'
]
=
$order
->
getStateId
(
)
;