setOrder example



        $orderRouteResponse = $this->getOrder($request$salesChannelContext);

        /** @var OrderEntity $order */
        $order = $orderRouteResponse->getOrders()->first();

        if ($this->isOrderPaid($order)) {
            throw OrderException::orderAlreadyPaid($order->getId());
        }

        $page->setOrder($order);
        $page->setPaymentChangeable($this->isPaymentChangeable($orderRouteResponse$page));
        $page->setPaymentMethods($this->getPaymentMethods($salesChannelContext$request$order));
        $page->setDeepLinkCode($request->get('deepLinkCode'));

        $this->eventDispatcher->dispatch(
            new AccountEditOrderPageLoadedEvent($page$salesChannelContext$request)
        );

        return $page;
    }

    
$attribute = new OrderDetailAttribute();
            $position->setAttribute($attribute);
            $this->getManager()->persist($position);
        }

        $data = $this->Request()->getParams();
        $data['number'] = $order->getNumber();

        $data = $this->getPositionAssociatedData($data$order);

        $position->fromArray($data);
        $position->setOrder($order);

        $this->getManager()->flush();

        // If the passed data is a new position, the flush function will add the new id to the position model         $data['id'] = $position->getId();

        // The position model will refresh the product stock, so the product stock         // will be assigned to the view to refresh the grid or form panel.         $variant = $this->getManager()->getRepository(ProductVariant::class)
            ->findOneBy(['number' => $position->getArticleNumber()]);
        if ($variant instanceof ProductVariant) {
            

class PaymentServiceTest extends TestCase
{
    public function testFinalize(): void
    {
        $transactionId = Uuid::randomHex();
        $transaction = new OrderTransactionEntity();
        $transaction->setId($transactionId);
        $order = new OrderEntity();
        $order->setId(Uuid::randomHex());
        $transaction->setOrder($order);
        $context = Generator::createSalesChannelContext();
        $request = new Request();

        $tokenFactory = $this->createMock(JWTFactoryV2::class);
        $tokenFactory->expects(static::once())->method('parseToken')->with('paymentToken')->willReturn(new TokenStruct('id', 'token', 'paymentMethodId', $transactionId, 'finishUrl', \PHP_INT_MAX));
        $tokenFactory->expects(static::once())->method('invalidateToken')->with('token');

        $eventDispatcher = $this->createMock(EventDispatcherInterface::class);
        $eventDispatcher->expects(static::once())->method('dispatch')->with(static::isInstanceOf(FinalizePaymentOrderTransactionCriteriaEvent::class));

        $transactionRepository = $this->createMock(EntityRepository::class);
        
        $billingAddress = array_map(function D$value) {
            return (string) $value;
        }$result[0]['customer']['defaultBillingAddress']);

        $billingCountry = $this->get('models')->find(Country::class$result[0]['customer']['defaultBillingAddress']['countryId']);

        // Create new entry in s_order_billingaddress         $billingModel = new Shopware\Models\Order\Billing();
        $billingModel->fromArray($billingAddress);
        $billingModel->setCountry($billingCountry);
        $billingModel->setCustomer($customer);
        $billingModel->setOrder($orderModel);
        $this->get('models')->persist($billingModel);

        // Casting null values to empty strings to fulfill the restrictions of the s_order_shippingaddress table         $shippingAddress = array_map(function D$value) {
            return (string) $value;
        }$result[0]['customer']['defaultShippingAddress']);

        $shippingCountry = $this->get('models')->find(Country::class$result[0]['customer']['defaultShippingAddress']['countryId']);

        // Create new entry in s_order_shippingaddress         $shippingModel = new Shopware\Models\Order\Shipping();
        
if ($type instanceof Mail) {
            $logEntry->setType($type);
        }
    }

    protected function assignOrder(Log $logEntry, Enlight_Components_Mail $mail): void
    {
        $order = $this->resolveOrderByAssociation($mail);

        if ($order !== null) {
            $logEntry->setOrder($order);

            return;
        }

        $order = $this->resolveOrderByType($logEntry->getType());

        if ($order !== null) {
            $logEntry->setOrder($order);
        }
    }

    
$result = $this->orderRoute
            ->load($event->getStoreApiRequest()$salesChannelContext$criteria);

        $order = $result->getOrders()->first();

        if (!$order instanceof OrderEntity) {
            throw new NotFoundHttpException();
        }

        $page = AccountOrderDetailPage::createFrom($this->genericLoader->load($request$salesChannelContext));
        $page->setLineItems($order->getNestedLineItems());
        $page->setOrder($order);

        if ($page->getMetaInformation()) {
            $page->getMetaInformation()->setRobots('noindex,follow');
        }

        $this->eventDispatcher->dispatch(
            new AccountOrderDetailPageLoadedEvent($page$salesChannelContext$request)
        );

        return $page;
    }
}
$config,
            [
                'subject' => $document,
                'orderID' => $orderID,
                'documentID' => $documentID,
            ]
        );

        /** @var Shopware_Models_Document_Order $documentOrder */
        $documentOrder = Enlight_Class::Instance('Shopware_Models_Document_Order', [$orderID$config]);

        $document->setOrder($documentOrder);

        $document->setConfig($config);

        $document->setDocumentId($documentID);
        if (!empty($orderID)) {
            $document->_subshop = Shopware()->Db()->fetchRow(
                "SELECT s.id, m.document_template_id as doc_template_id, m.template_id as template_id, (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = m.document_template_id) as doc_template, (SELECT CONCAT('templates/', template) FROM s_core_templates WHERE id = m.template_id) as template, s.id as isocode, s.locale_id as locale FROM s_order, s_core_shops s LEFT JOIN s_core_shops m ON m.id=s.main_id OR (s.main_id IS NULL AND m.id=s.id) WHERE s_order.language = s.id AND s_order.id = ?",
public function load(Request $request, SalesChannelContext $salesChannelContext): CheckoutFinishPage
    {
        $page = $this->genericLoader->load($request$salesChannelContext);

        $page = CheckoutFinishPage::createFrom($page);

        if ($page->getMetaInformation()) {
            $page->getMetaInformation()->setRobots('noindex,follow');
        }

        Profiler::trace('finish-page-order-loading', function D) use ($page$request$salesChannelContext): void {
            $page->setOrder($this->getOrder($request$salesChannelContext));
        });

        $page->setChangedPayment((bool) $request->get('changedPayment', false));

        $page->setPaymentFailed((bool) $request->get('paymentFailed', false));

        $this->eventDispatcher->dispatch(
            new CheckoutFinishPageLoadedEvent($page$salesChannelContext$request)
        );

        if ($page->getOrder()->getItemRounding()) {
            
Home | Imprint | This part of the site doesn't use cookies.