Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
paymentMethodNotChangeable example
'changedPayment' => true,
]
)
;
/** @var OrderEntity|null $order */
$order
=
$this
->orderRoute->
load
(
$request
,
$context
,
new
Criteria
(
[
$orderId
]
)
)
->
getOrders
(
)
->
first
(
)
;
if
(
$order
=== null
)
{
throw
OrderException::
orderNotFound
(
$orderId
)
;
}
if
(
!
$this
->orderService->
isPaymentChangeableByTransactionState
(
$order
)
)
{
throw
OrderException::
paymentMethodNotChangeable
(
)
;
}
if
(
$context
->
getCurrency
(
)
->
getId
(
)
!==
$order
->
getCurrencyId
(
)
)
{
$this
->contextSwitchRoute->
switchContext
(
new
RequestDataBag
(
[
SalesChannelContextService::CURRENCY_ID =>
$order
->
getCurrencyId
(
)
]
)
,
$context
)
;
$context
=
$this
->contextService->
get
(
new
SalesChannelContextServiceParameters
(
$context
->
getSalesChannelId
(
)
,