Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getOldPaymentMethodName example
public
function
isPersistent
(
)
: bool
{
return
true;
}
public
function
getParameters
(
)
: array
{
return
[
'newPaymentMethodName' =>
$this
->
getNewPaymentMethodName
(
)
,
'oldPaymentMethodName' =>
$this
->
getOldPaymentMethodName
(
)
,
]
;
}
public
function
blockOrder
(
)
: bool
{
return
false;
}
public
function
getId
(
)
: string
{
return
sprintf
(
'%s-%s-%s', self::KEY,
$this
->oldPaymentMethodName,
$this
->newPaymentMethodName
)
;
}
foreach
(
$cartErrors
as
$error
)
{
if
(
!
$error
instanceof ShippingMethodChangedError && !
$error
instanceof PaymentMethodChangedError
)
{
continue
;
}
if
(
$error
instanceof ShippingMethodChangedError
)
{
$cartErrors
->
add
(
new
ShippingMethodBlockedError
(
$error
->
getOldShippingMethodName
(
)
)
)
;
}
if
(
$error
instanceof PaymentMethodChangedError
)
{
$cartErrors
->
add
(
new
PaymentMethodBlockedError
(
$error
->
getOldPaymentMethodName
(
)
)
)
;
}
$cartErrors
->
remove
(
$error
->
getId
(
)
)
;
}
}
}
SalesChannelContextService::SHIPPING_METHOD_ID =>
$blockedId
,
]
)
;
}
return
;
}
if
(
$error
instanceof PaymentMethodChangedError
)
{
$paymentMethodRepository
=
$this
->
getContainer
(
)
->
get
(
'payment_method.repository'
)
;
$blockedId
=
$this
->
getPaymentMethodIdByName
(
$error
->
getOldPaymentMethodName
(
)
)
;
$newId
=
$this
->
getPaymentMethodIdByName
(
$error
->
getNewPaymentMethodName
(
)
)
;
$paymentMethodRepository
->
update
(
[
[
'id' =>
$blockedId
,
'availabilityRuleId' =>
$availabilityRuleId
,
]
,
]
, Context::
createDefaultContext
(
)
)
;
$salesChannelRepository
->
update
(
[
[