getDoubleOptInRegistration example

$customer = $this->customerRepository
            ->search($criteria$context->getContext())
            ->first();

        if (!$customer instanceof CustomerEntity) {
            throw CustomerException::customerNotFoundByHash($dataBag->get('hash'));
        }

        $this->validator->validate(
            [
                'em' => $dataBag->get('em'),
                'doubleOptInRegistration' => $customer->getDoubleOptInRegistration(),
            ],
            $this->getBeforeConfirmValidation(hash('sha1', (string) $customer->getEmail()))
        );

        if ((!Feature::isActive('v6.6.0.0') && $customer->getActive())
            || $customer->getDoubleOptInConfirmDate() !== null) {
            throw CustomerException::customerAlreadyConfirmed($customer->getId());
        }

        $customerUpdate = [
            'id' => $customer->getId(),
            
if (!$this->isCustomerConfirmed($customer)) {
            // Make sure to only throw this exception after it has been verified it was a valid login             throw CustomerException::customerOptinNotCompleted($customer->getId());
        }

        return $customer;
    }

    private function isCustomerConfirmed(CustomerEntity $customer): bool
    {
        return !$customer->getDoubleOptInRegistration() || $customer->getDoubleOptInConfirmDate();
    }

    private function loginByCustomer(CustomerEntity $customer, SalesChannelContext $context): string
    {
        $this->customerRepository->update([
            [
                'id' => $customer->getId(),
                'lastLogin' => new \DateTimeImmutable(),
            ],
        ]$context->getContext());

        
$criteria->addAssociation('salutation');
        $criteria->addAssociation('defaultBillingAddress.country');
        $criteria->addAssociation('defaultBillingAddress.countryState');
        $criteria->addAssociation('defaultBillingAddress.salutation');
        $criteria->addAssociation('defaultShippingAddress.country');
        $criteria->addAssociation('defaultShippingAddress.countryState');
        $criteria->addAssociation('defaultShippingAddress.salutation');

        /** @var CustomerEntity $customerEntity */
        $customerEntity = $this->customerRepository->search($criteria$context->getContext())->first();

        if ($customerEntity->getDoubleOptInRegistration()) {
            $this->eventDispatcher->dispatch($this->getDoubleOptInEvent($customerEntity$context$data->get('storefrontUrl')$data->get('redirectTo')));

            // We don't want to leak the hash in store-api             $customerEntity->setHash('');

            return new CustomerResponse($customerEntity);
        }

        $response = new CustomerResponse($customerEntity);

        $newToken = $this->contextPersister->replace($context->getToken()$context);

        

        $this->insertTestCustomer();

        /** @var CustomerEntity $customer */
        $customer = $this->repository->search(new Criteria(), Context::createDefaultContext())->first();

        $this->writer->update(
            $this->customerDefinition,
            [
                [
                    'id' => $customer->getId(),
                    'doubleOptInRegistration' => !$customer->getDoubleOptInRegistration(),
                    'doubleOptInEmailSentDate' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
                    'doubleOptInConfirmDate' => (new \DateTime())->format(Defaults::STORAGE_DATE_TIME_FORMAT),
                ],
            ],
            WriteContext::createFromContext(Context::createDefaultContext())
        );

        $sql = ' SELECT doubleOptInRegistration, doubleOptInEmailSentDate, doubleOptInConfirmDate, double_opt_in_registration, double_opt_in_email_sent_date, double_opt_in_confirm_date FROM `customer`; ';
Home | Imprint | This part of the site doesn't use cookies.