getBillingAddressId example

$customerId = $order->getOrderCustomer()->getCustomerId();
        $customerGroupId = null;

        if ($customerId) {
            /** @var CustomerEntity|null $customer */
            $customer = $this->customerRepository->search(new Criteria([$customerId])$context)->get($customerId);
            if ($customer !== null) {
                $customerGroupId = $customer->getGroupId();
            }
        }

        $billingAddressId = $order->getBillingAddressId();
        $billingAddress = $this->orderAddressRepository->search(new Criteria([$billingAddressId])$context)->get($billingAddressId);
        if (!$billingAddress instanceof OrderAddressEntity) {
            throw CartException::addressNotFound($billingAddressId);
        }

        $options = [
            SalesChannelContextService::CURRENCY_ID => $order->getCurrencyId(),
            SalesChannelContextService::LANGUAGE_ID => $order->getLanguageId(),
            SalesChannelContextService::CUSTOMER_ID => $customerId,
            SalesChannelContextService::COUNTRY_STATE_ID => $billingAddress->getCountryStateId(),
            SalesChannelContextService::CUSTOMER_GROUP_ID => $customerGroupId,
            
$amount_net = 'b.quantity*CAST(b.price as DECIMAL(10,2))';
        } else {
            $amount = 'b.quantity*CAST(b.price as DECIMAL(10,2))';
            $amount_net = 'b.quantity*ROUND(CAST(b.price as DECIMAL(10,2))/(100+t.tax)*100,2)';
        }

        $queryBuilder = $this->getBasketQueryBuilder($amount$amount_net);

        $queryBuilder->setParameters([
            'userId' => $userId,
            'sessionId' => empty($sessionId) ? session_id() : $sessionId,
            'billingAddressId' => $this->getBillingAddressId(),
            'shippingAddressId' => $this->getShippingAddressId(),
        ]);

        foreach ($addSelect as $select) {
            $queryBuilder->addSelect($select);
        }

        $this->eventManager->notify(
            'Shopware_Modules_Admin_GetDispatchBasket_QueryBuilder',
            [
                'queryBuilder' => $queryBuilder,
                
/** @var OrderEntity $order */
                $order = $container->get('order.repository')
                    ->search($criteria, Context::createDefaultContext())->get($orderId);

                static::assertNotNull($order->getOrderCustomer());
                $container->get('customer.repository')->update([[
                    'id' => $order->getOrderCustomer()->getCustomerId(),
                    'vatIds' => ['VAT-123123'],
                ]], Context::createDefaultContext());

                static::assertNotNull($order->getAddresses());
                static::assertNotNull($order->getAddresses()->get($order->getBillingAddressId()));
                static::assertNotNull($order->getAddresses()->get($order->getBillingAddressId())->getCountry());
                $container->get('country.repository')->upsert([[
                    'id' => $order->getAddresses()->get($order->getBillingAddressId())->getCountry()->getId(),
                    'companyTax' => ['amount' => 0, 'enabled' => true, 'currencyId' => Context::createDefaultContext()->getCurrencyId()],
                ]], Context::createDefaultContext());

                $operation->assign([
                    'config' => [
                        'displayLineItems' => true,
                        'displayHeader' => true,
                        'displayCustomerVatId' => true,
                        
Home | Imprint | This part of the site doesn't use cookies.