getCity example

$date = new DateTime();
        $data = [
            'payment_mean_id' => $paymentId,
            'order_id' => $orderId,
            'user_id' => $userId,

            'firstname' => $paymentData['sSepaUseBillingData'] ? $addressData->getFirstname() : null,
            'lastname' => $paymentData['sSepaUseBillingData'] ? $addressData->getLastname() : null,
            'address' => $paymentData['sSepaUseBillingData'] ? $addressData->getStreet() : null,
            'zipcode' => $paymentData['sSepaUseBillingData'] ? $addressData->getZipcode() : null,
            'city' => $paymentData['sSepaUseBillingData'] ? $addressData->getCity() : null,

            'bank_name' => $paymentData['sSepaBankName'],
            'account_holder' => $paymentData['sSepaUseBillingData'] ? ($addressData->getFirstname() . ' ' . $addressData->getLastname()) : null,
            'bic' => $paymentData['sSepaBic'],
            'iban' => $paymentData['sSepaIban'],

            'amount' => $order['invoiceAmount'],
            'created_at' => $date->format('Y-m-d'),
        ];

        $data = Shopware()->Container()->get('events')->filter('Sepa_Payment_Method_Create_Payment_Instance_Data', $data[
            
$dataBag->set('email', $customer->getEmail());
        $dataBag->set('salutationId', $customer->getSalutationId());
        $dataBag->set('title', $customer->getTitle());
        $dataBag->set('firstName', $customer->getFirstName());
        $dataBag->set('lastName', $customer->getLastName());
        $dataBag->set(
            'zipCode',
            $customer->getDefaultShippingAddress() ? $customer->getDefaultShippingAddress()->getZipCode() : ''
        );
        $dataBag->set(
            'city',
            $customer->getDefaultShippingAddress() ? $customer->getDefaultShippingAddress()->getCity() : ''
        );
        $dataBag->set(
            'street',
            $customer->getDefaultShippingAddress() ? $customer->getDefaultShippingAddress()->getStreet() : ''
        );

        return $dataBag;
    }
}

            },
            function DRenderedDocument $rendered, OrderEntity $order): void {
                static::assertNotNull($orderDeliveries = $order->getDeliveries());
                $shippingAddress = $orderDeliveries->getShippingAddress()->first();
                static::assertNotNull($shippingAddress);

                $rendered = $rendered->getHtml();

                static::assertStringContainsString('Shipping address', $rendered);
                static::assertStringContainsString($shippingAddress->getStreet()$rendered);
                static::assertStringContainsString($shippingAddress->getCity()$rendered);
                static::assertStringContainsString($shippingAddress->getFirstName()$rendered);
                static::assertStringContainsString($shippingAddress->getLastName()$rendered);
                static::assertStringContainsString($shippingAddress->getZipcode()$rendered);
                static::assertStringContainsString('Intra-community delivery (EU)', $rendered);
                static::assertStringContainsString('123123123', $rendered);
            },
        ];

        yield 'render with billing address' => [
            [7],
            function DDocumentGenerateOperation $operation, ContainerInterface $container): void {
                
$additional = $address->getAdditional();
        $customerType = !empty($additional['customer_type']) ? $additional['customer_type'] : null;

        if ($this->config->get('shopSalutationRequired')) {
            $this->validateField('salutation', $address->getSalutation()[new NotBlank()]);
        }
        $this->validateField('firstname', $address->getFirstname()[new NotBlank()]);
        $this->validateField('lastname', $address->getLastname()[new NotBlank()]);
        $this->validateField('street', $address->getStreet()[new NotBlank()]);
        $this->validateField('zipcode', $address->getZipcode()[new NotBlank()]);
        $this->validateField('city', $address->getCity()[new NotBlank()]);
        $this->validateField('country', $address->getCountry() ? $address->getCountry() : null, [new NotBlank()]);
        $this->validateField('phone', $address->getPhone()$this->getPhoneConstraints());
        $this->validateField('additionalAddressLine1', $address->getAdditionalAddressLine1()$this->getAdditionalAddressline1Constraints());
        $this->validateField('additionalAddressLine2', $address->getAdditionalAddressLine2()$this->getAdditionalAddressline2Constraints());

        if ($address->getCountry() && $address->getCountry()->getForceStateInRegistration()) {
            $this->validateField('state', $address->getState()[new NotBlank()]);
        }

        if ($customerType === Customer::CUSTOMER_TYPE_BUSINESS) {
            $this->validateField('company', $address->getCompany()[new NotBlank()]);

            

        return array_filter([
            'id' => Uuid::randomHex(),
            'company' => $address->getCompany(),
            'department' => $address->getDepartment(),
            'salutationId' => $address->getSalutationId(),
            'title' => $address->getTitle(),
            'firstName' => $address->getFirstName(),
            'lastName' => $address->getLastName(),
            'street' => $address->getStreet(),
            'zipcode' => $address->getZipcode(),
            'city' => $address->getCity(),
            'phoneNumber' => $address->getPhoneNumber(),
            'additionalAddressLine1' => $address->getAdditionalAddressLine1(),
            'additionalAddressLine2' => $address->getAdditionalAddressLine2(),
            'countryId' => $address->getCountryId(),
            'countryStateId' => $address->getCountryStateId(),
            'customFields' => $address->getCustomFields(),
        ]);
    }
}
'firstname' => $customer->getFirstname(),
            'lastname' => $customer->getLastname(),
            'birthday' => $this->formatDate($customer->getBirthday()),
            'customernumber' => $customer->getNumber(),
            'customer_group_id' => $customer->getCustomerGroup() ? $customer->getCustomerGroup()->getId() : null,
            'customer_group_name' => $customer->getCustomerGroup() ? $customer->getCustomerGroup()->getName() : '',
            'payment_id' => $customer->getPaymentId(),
            'company' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getCompany() : '',
            'department' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getDepartment() : '',
            'street' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getStreet() : '',
            'zipcode' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getZipcode() : '',
            'city' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getCity() : '',
            'phone' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getPhone() : '',
            'additional_address_line1' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getAdditionalAddressLine1() : '',
            'additional_address_line2' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getAdditionalAddressLine2() : '',
            'country_id' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getCountryId() : null,
            'country_name' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getCountry()->getName() : '',
            'state_id' => $customer->getBillingAddress() ? $customer->getBillingAddress()->getStateId() : '',
            'age' => $customer->getAge(),
            'count_orders' => (int) $customer->getOrderInformation()->getOrderCount(),
            'product_avg' => (float) $customer->getOrderInformation()->getAvgProductPrice(),
            'invoice_amount_sum' => (float) $customer->getOrderInformation()->getTotalAmount(),
            'invoice_amount_avg' => (float) $customer->getOrderInformation()->getAvgAmount(),
            
/** * Transfer values from the new address object */
    public function fromAddress(Address $address)
    {
        $this->setCompany((string) $address->getCompany());
        $this->setDepartment((string) $address->getDepartment());
        $this->setSalutation((string) $address->getSalutation());
        $this->setFirstName((string) $address->getFirstname());
        $this->setLastName((string) $address->getLastname());
        $this->setStreet((string) $address->getStreet());
        $this->setCity((string) $address->getCity());
        $this->setZipCode((string) $address->getZipcode());
        $this->setAdditionalAddressLine1((string) $address->getAdditionalAddressLine1());
        $this->setAdditionalAddressLine2((string) $address->getAdditionalAddressLine2());
        $this->setCountry($address->getCountry());
        $this->setPhone($address->getPhone());
        $this->setTitle($address->getTitle());
        if ($address->getState()) {
            $this->setState($address->getState());
        } else {
            $this->setState(null);
        }

        
$output = array_merge($output[
            'id' => $address->getId(),
            'userID' => $address->getCustomer()->getId(),
            'company' => $address->getCompany(),
            'department' => $address->getDepartment(),
            'salutation' => $address->getSalutation(),
            'title' => $address->getTitle(),
            'firstname' => $address->getFirstname(),
            'lastname' => $address->getLastname(),
            'street' => $address->getStreet(),
            'zipcode' => $address->getZipcode(),
            'city' => $address->getCity(),
            'phone' => $address->getPhone(),
            'countryID' => $address->getCountry()->getId(),
            'stateID' => $address->getState() ? $address->getState()->getId() : null,
            'ustid' => $address->getVatId(),
            'additional_address_line1' => $address->getAdditionalAddressLine1(),
            'additional_address_line2' => $address->getAdditionalAddressLine2(),
            'attributes' => [],
        ]);

        if ($address->getAttribute()) {
            $data = Shopware()->Models()->toArray($address->getAttribute());

            
/** * Transfer values from the new address object */
    public function fromAddress(Address $address)
    {
        $this->setCompany((string) $address->getCompany());
        $this->setDepartment((string) $address->getDepartment());
        $this->setSalutation((string) $address->getSalutation());
        $this->setFirstName((string) $address->getFirstname());
        $this->setLastName((string) $address->getLastname());
        $this->setStreet((string) $address->getStreet());
        $this->setCity((string) $address->getCity());
        $this->setZipCode((string) $address->getZipcode());
        $this->setAdditionalAddressLine1((string) $address->getAdditionalAddressLine1());
        $this->setAdditionalAddressLine2((string) $address->getAdditionalAddressLine2());
        $this->setCountry($address->getCountry());
        $this->setPhone((string) $address->getPhone());
        $this->setVatId((string) $address->getVatId());
        $this->setTitle($address->getTitle());

        if ($address->getState()) {
            $this->setState($address->getState());
        } else {
            
/** @var OrderEntity $order */
        $order = $this->getContainer()->get('order.repository')->search($criteria$this->context->createWithVersionId($versionId))->get($orderId);
        static::assertNotNull($order);
        static::assertNotNull($order->getAddresses());
        /** @var OrderAddressEntity $orderAddress */
        $orderAddress = $order->getAddresses()->first();

        static::assertSame($orderAddressId$orderAddress->getId());
        static::assertSame($firstName$orderAddress->getFirstName());
        static::assertSame($lastName$orderAddress->getLastName());
        static::assertSame($street$orderAddress->getStreet());
        static::assertSame($city$orderAddress->getCity());
        static::assertSame($zipcode$orderAddress->getZipcode());
    }

    protected function getValidCountryIdWithTaxes(): string
    {
        /** @var EntityRepository $repository */
        $repository = $this->getContainer()->get('country.repository');

        $countryId = $this->getValidCountryId();

        $data = [
            
return RuleComparison::isNegativeOperator($this->operator);
        }

        if (!$address = $customer->getActiveBillingAddress()) {
            return RuleComparison::isNegativeOperator($this->operator);
        }

        if (!\is_string($this->cityName) && $this->operator !== self::OPERATOR_EMPTY) {
            throw new UnsupportedValueException(\gettype($this->cityName), self::class);
        }

        return RuleComparison::string($address->getCity()$this->cityName ?? '', $this->operator);
    }

    public function getConstraints(): array
    {
        $constraints = [
            'operator' => [
                new NotBlank(),
                new Choice([Rule::OPERATOR_EQ, Rule::OPERATOR_NEQ, Rule::OPERATOR_EMPTY]),
            ],
        ];

        
class BillingAddressSalutationMissingError extends SalutationMissingError
{
    protected const KEY = parent::KEY . '-billing-address';

    public function __construct(CustomerAddressEntity $address)
    {
        $this->message = sprintf(
            'A salutation needs to be defined for the billing address "%s %s, %s %s".',
            $address->getFirstName(),
            $address->getLastName(),
            $address->getZipcode(),
            $address->getCity()
        );

        $this->parameters = [
            'addressId' => $address->getId(),
        ];

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

    public function getId(): string
    {
        
static::assertSame($serialized['orderNumber']$order->getOrderNumber());
        static::assertSame($serialized['salesChannelId']$order->getSalesChannelId());

        static::assertInstanceOf(OrderCustomerEntity::class$orderCustomer = $serialized['orderCustomer']);
        static::assertSame($orderCustomer->getFirstName()$order->getOrderCustomer()->getFirstName());
        static::assertSame($orderCustomer->getLastName()$order->getOrderCustomer()->getLastName());
        static::assertSame($orderCustomer->getEmail()$order->getOrderCustomer()->getEmail());

        static::assertInstanceOf(OrderAddressEntity::class$billingAddress = $serialized['billingAddress']);
        static::assertSame($billingAddress->getZipcode()$order->getBillingAddress()->getZipcode());
        static::assertSame($billingAddress->getStreet()$order->getBillingAddress()->getStreet());
        static::assertSame($billingAddress->getCity()$order->getBillingAddress()->getCity());
        static::assertSame($billingAddress->getCompany()$order->getBillingAddress()->getCompany());
        static::assertSame($billingAddress->getDepartment()$order->getBillingAddress()->getDepartment());
        static::assertSame($billingAddress->getCountryId()$order->getBillingAddress()->getCountryId());
        static::assertSame($billingAddress->getCountryStateId()$order->getBillingAddress()->getCountryStateId());

        static::assertNotNull($deliveries = $order->getDeliveries());
        static::assertNotNull($delivery = $deliveries->first());
        $shippingAddress = $delivery->getShippingOrderAddress();

        static::assertNotNull($shippingAddress);

        
return false;
        }

        if (!$address = $scope->getSalesChannelContext()->getShippingLocation()->getAddress()) {
            return RuleComparison::isNegativeOperator($this->operator);
        }

        if (!\is_string($this->cityName) && $this->operator !== self::OPERATOR_EMPTY) {
            throw new UnsupportedValueException(\gettype($this->cityName), self::class);
        }

        return RuleComparison::string($address->getCity()$this->cityName ?? '', $this->operator);
    }

    public function getConstraints(): array
    {
        $constraints = [
            'operator' => [
                new NotBlank(),
                new Choice([Rule::OPERATOR_EQ, Rule::OPERATOR_NEQ, Rule::OPERATOR_EMPTY]),
            ],
        ];

        
class ShippingAddressSalutationMissingError extends SalutationMissingError
{
    protected const KEY = parent::KEY . '-shipping-address';

    public function __construct(CustomerAddressEntity $address)
    {
        $this->message = sprintf(
            'A salutation needs to be defined for the shipping address "%s %s, %s %s".',
            $address->getFirstName(),
            $address->getLastName(),
            $address->getZipcode(),
            $address->getCity()
        );

        $this->parameters = [
            'addressId' => $address->getId(),
        ];

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

    public function getId(): string
    {
        
Home | Imprint | This part of the site doesn't use cookies.