/**
* Remove all PaymentMethodChangedErrors and ShippingMethodChangedErrors from cart
*/
private function removeSwitchNotices(ErrorCollection
$cartErrors): void
{ 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());
} }}