getCustomerNumber example

return false;
        }

        if (!$customer = $scope->getSalesChannelContext()->getCustomer()) {
            return RuleComparison::isNegativeOperator($this->operator);
        }

        if (!\is_array($this->numbers)) {
            throw new UnsupportedValueException(\gettype($this->numbers), self::class);
        }

        return RuleComparison::stringArray($customer->getCustomerNumber()array_map('strtolower', $this->numbers)$this->operator);
    }

    public function getConstraints(): array
    {
        return [
            'numbers' => RuleConstraints::stringArray(),
            'operator' => RuleConstraints::stringOperators(false),
        ];
    }

    public function getConfig(): RuleConfig
    {
$result = $customerRepository->search(new Criteria([
            $this->ids->get('10000'),
            $this->ids->get('10001'),
        ])$context);

        static::assertEquals(1, $result->getTotal());

        /** @var CustomerEntity $entity */
        $entity = $result->first();

        // expect the non-guest customer to still exist         static::assertEquals('10000', $entity->getCustomerNumber());
    }

    public function testItDeletesOnlyExpiredCustomerAccounts(): void
    {
        $context = Context::createDefaultContext();
        $customerRepository = $this->getContainer()->get('customer.repository');

        $nonExpiredCustomer = (new CustomerBuilder($this->ids, '10000'))
            ->add('guest', true)
            // guest account is not expired as max lifetime is 86400s = 24 hours             ->add('createdAt', new \DateTime('- 2 hours'));

        
static::assertNotEmpty($documentStruct->getContent());
    }

    public function testPreviewStorno(): void
    {
        $order = $this->getContainer()->get('order.repository')->search(new Criteria([$this->orderId])$this->context)->first();
        static::assertNotNull($order);
        static::assertInstanceOf(OrderEntity::class$order);
        $orderCustomer = $order->getOrderCustomer();
        static::assertNotNull($orderCustomer);
        $customerNo = (string) $orderCustomer->getCustomerNumber();

        $invoiceNumber = '9998';
        $invoiceConfig1 = new DocumentConfiguration();
        $invoiceConfig1->setDocumentNumber($invoiceNumber);

        $invoiceConfig2 = new DocumentConfiguration();
        $invoiceConfig2->setDocumentNumber('9999');

        $operation1 = new DocumentGenerateOperation($this->orderId, FileTypes::PDF, $invoiceConfig1->jsonSerialize());
        $operation2 = new DocumentGenerateOperation($this->orderId, FileTypes::PDF, $invoiceConfig2->jsonSerialize());

        
public static function transform(CustomerEntity $customer): array
    {
        return [
            'customerId' => $customer->getId(),
            'email' => $customer->getEmail(),
            'firstName' => $customer->getFirstName(),
            'lastName' => $customer->getLastName(),
            'salutationId' => $customer->getSalutationId(),
            'title' => $customer->getTitle(),
            'vatIds' => $customer->getVatIds(),
            'company' => $customer->getCompany(),
            'customerNumber' => $customer->getCustomerNumber(),
            'remoteAddress' => $customer->getRemoteAddress(),
            'customFields' => $customer->getCustomFields(),
        ];
    }
}

#[Package('checkout')] class ProfileSalutationMissingError extends SalutationMissingError
{
    protected const KEY = parent::KEY . '-profile';

    public function __construct(CustomerEntity $customer)
    {
        $this->message = sprintf(
            'A salutation needs to be defined for the customer profile %s, %s %s.',
            $customer->getCustomerNumber(),
            $customer->getFirstName(),
            $customer->getLastName()
        );

        $this->parameters = [
            'entityId' => $customer->getId(),
        ];

        parent::__construct($this->message);
    }

    
// we use assigned customers             // check if we have customers.             // if so, create customer rules for it and add that also as             // a separate OR condition to our main persona rule             if ($this->getPersonaCustomers() !== null) {
                $personaCustomerOR = new OrRule();

                foreach ($this->getPersonaCustomers()->getElements() as $customer) {
                    // build our new rule for this                     // customer and his/her customer number                     $custRule = new CustomerNumberRule();
                    $custRule->assign(['numbers' => [$customer->getCustomerNumber()], 'operator' => CustomerNumberRule::OPERATOR_EQ]);

                    $personaCustomerOR->addRule($custRule);
                }

                // add the rule to our main rule                 $requirements->addRule($personaCustomerOR);
            }
        } else {
            // we use persona rules.             // check if we have persona rules and add them             // to our persona OR as a separate OR rule with all configured rules
Home | Imprint | This part of the site doesn't use cookies.