Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
setIncludeTransactions example
$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
(
)
;
if
(
$order
->
getDeliveries
(
)
?->
first
(
)
?->
getStateId
(
)
)
{
$orderData
[
'deliveries'
]
[
0
]
[
'stateId'
]
=
$order
->
getDeliveries
(
)
->
first
(
)
->
getStateId
(
)
;
}
// change scope to be able to write protected state fields of transactions and deliveries
$context
->
scope
(
Context::SYSTEM_SCOPE,
function
DContext
$context
)
use
(
$orderData
)
: void
{