cannotDeleteActiveAddress example

 {
            throw CustomerException::cannotDeleteDefaultAddress($addressId);
        }

        $activeBillingAddress = $customer->getActiveBillingAddress();
        $activeShippingAddress = $customer->getActiveShippingAddress();

        if (
            ($activeBillingAddress && $addressId === $activeBillingAddress->getId())
            || ($activeShippingAddress && $addressId === $activeShippingAddress->getId())
        ) {
            throw CustomerException::cannotDeleteActiveAddress($addressId);
        }

        $this->addressRepository->delete([['id' => $addressId]]$context->getContext());

        return new NoContentResponse();
    }
}
'message' => 'Customer address with id "id-1" not found.',
        ];

        yield CustomerException::CUSTOMER_AUTH_BAD_CREDENTIALS => [
            'exception' => CustomerException::badCredentials(),
            'statusCode' => Response::HTTP_UNAUTHORIZED,
            'errorCode' => CustomerException::CUSTOMER_AUTH_BAD_CREDENTIALS,
            'message' => 'Invalid username and/or password.',
        ];

        yield CustomerException::CUSTOMER_ADDRESS_IS_ACTIVE => [
            'exception' => CustomerException::cannotDeleteActiveAddress('id-1'),
            'statusCode' => Response::HTTP_BAD_REQUEST,
            'errorCode' => CustomerException::CUSTOMER_ADDRESS_IS_ACTIVE,
            'message' => 'Customer address with id "id-1" is an active address and cannot be deleted.',
        ];

        yield CustomerException::CUSTOMER_ADDRESS_IS_DEFAULT => [
            'exception' => CustomerException::cannotDeleteDefaultAddress('id-1'),
            'statusCode' => Response::HTTP_BAD_REQUEST,
            'errorCode' => CustomerException::CUSTOMER_ADDRESS_IS_DEFAULT,
            'message' => 'Customer address with id "id-1" is a default address and cannot be deleted.',
        ];

        
Home | Imprint | This part of the site doesn't use cookies.