getOrder example


        }
    }

    public function orderPlaced(CheckoutOrderPlacedEvent $event): void
    {
        if ($this->isDisabled()) {
            return;
        }

        $ids = [];
        foreach ($event->getOrder()->getLineItems() ?? [] as $lineItem) {
            if ($lineItem->getType() !== LineItem::PRODUCT_LINE_ITEM_TYPE) {
                continue;
            }

            $referencedId = $lineItem->getReferencedId();
            if (!$referencedId) {
                continue;
            }

            if (!\array_key_exists($referencedId$ids)) {
                $ids[$referencedId] = 0;
            }
$criteria->addAssociation('transactionCapture.transaction.paymentMethod.appPaymentMethod.app');
        $criteria->addAssociation('transactionCapture.positions');

        $refund = $this->refundRepository->search($criteria$context)->first();

        if (!($refund instanceof OrderTransactionCaptureRefundEntity)) {
            throw PaymentException::unknownRefund($refundId);
        }

        if (!$refund->getTransactionCapture()
            || !$refund->getTransactionCapture()->getTransaction()
            || !$refund->getTransactionCapture()->getTransaction()->getOrder()
        ) {
            return;
        }

        $transaction = $refund->getTransactionCapture()->getTransaction();
        $paymentMethod = $this->getAppPaymentMethod($transaction);
        $refundUrl = $paymentMethod->getRefundUrl();

        if (!$refundUrl) {
            return;
        }

        
$eventWasThrown = true;
            }
        );

        /** @var CheckoutFinishPageLoadedEvent $event */
        $event = null;
        $this->catchEvent(CheckoutFinishPageLoadedEvent::class$event);

        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(CheckoutFinishPage::class$page);
        static::assertSame(13.04, $page->getOrder()->getPrice()->getNetPrice());
        self::assertPageEvent(CheckoutFinishPageLoadedEvent::class$event$context$request$page);
        static::assertTrue($eventWasThrown);

        $this->resetEventDispatcher();
    }

    /** * @return CheckoutFinishPageLoader */
    protected function getPageLoader()
    {
        
$this->context = $this->getContainer()->get(SalesChannelContextFactory::class)
            ->create('test', TestDefaults::SALES_CHANNEL);

        $this->loader = $this->getContainer()->get(ProductConfiguratorLoader::class);

        parent::setUp();
    }

    public function testDefaultOrder(): void
    {
        $groupNames = $this->getOrder();
        static::assertEquals(['a', 'b', 'c', 'd', 'e', 'f']$groupNames);
    }

    public function testGroupPositionOrder(): void
    {
        $groupNames = $this->getOrder(['f', 'e', 'd', 'c', 'b', 'a']);
        static::assertEquals(['f', 'e', 'd', 'c', 'b', 'a']$groupNames);
    }

    public function testConfiguratorGroupConfigOrder(): void
    {
        
$constraints['documentIds'] = RuleConstraints::uuids();

        return $constraints;
    }

    public function match(RuleScope $scope): bool
    {
        if (!$scope instanceof FlowRuleScope) {
            return false;
        }

        if (!$documents = $scope->getOrder()->getDocuments()) {
            return false;
        }

        $typeIds = [];
        foreach ($documents->getElements() as $document) {
            $typeIds[] = $document->getDocumentTypeId();
        }

        return RuleComparison::uuids(array_values(array_unique($typeIds))$this->documentIds, $this->operator);
    }

    
/** * {@inheritdoc} */
  public function tableSort(&$headers) {
    // If 'field' is not initialized, the header columns aren't clickable.     foreach ($headers as $key => $header) {
      if (is_array($header) && isset($header['specifier'])) {
        $headers[$key]['field'] = '';
      }
    }

    $order = TableSort::getOrder($headers, \Drupal::request());
    $direction = TableSort::getSort($headers, \Drupal::request());
    foreach ($headers as $header) {
      if (is_array($header) && ($header['data'] == $order['name'])) {
        $this->sort($header['specifier']$direction$header['langcode'] ?? NULL);
      }
    }

    return $this;
  }

  /** * Makes sure that the Condition object is cloned as well. */
/** @var AccountEditOrderPageLoader $event */
        $event = null;
        $this->catchEvent(AccountEditOrderPageLoadedEvent::class$event);

        $request->request->set('orderId', $orderId);
        $page = $this->getPageLoader()->load($request$context);

        static::assertInstanceOf(AccountEditOrderPage::class$page);
        self::assertPageEvent(AccountEditOrderPageLoadedEvent::class$event$context$request$page);

        static::assertSame($orderId$page->getOrder()->getId());
    }

    public function testEditOrderPageCorrectPayment(): void
    {
        $request = new Request();
        $context = $this->createSalesChannelContextWithLoggedInCustomerAndWithNavigation();
        $orderId = $this->placeRandomOrder($context);

        /** @var AccountEditOrderPageLoader $event */
        $event = null;
        $this->catchEvent(AccountEditOrderPageLoadedEvent::class$event);

        
$criteria->addAssociation('order.transactions.stateMachineState');

        /** @var OrderDeliveryEntity|null $orderDelivery */
        $orderDelivery = $this->deliveryRepository
            ->search($criteria$event->getContext())
            ->first();

        if ($orderDelivery === null) {
            throw OrderException::orderDeliveryNotFound($orderDeliveryId);
        }

        if ($orderDelivery->getOrder() === null) {
            throw OrderException::orderDeliveryNotFound($orderDeliveryId);
        }

        $context = $this->getContext($orderDelivery->getOrderId()$event->getContext());
        $order = $this->getOrder($orderDelivery->getOrderId()$context);

        $this->dispatchEvent($event->getStateEventName()$order$context);
    }

    /** * @throws OrderException */

        $transaction = new OrderTransactionEntity();
        $order = new OrderEntity();
        $requestData = ['foo' => 'bar'];
        $recurring = new RecurringDataStruct('foo', new \DateTime());
        $source = new Source('foo', 'bar', '1.0.0');

        $payload = new RecurringPayPayload($transaction$order$requestData$recurring);
        $payload->setSource($source);

        static::assertEquals($transaction$payload->getOrderTransaction());
        static::assertSame($order$payload->getOrder());
        static::assertSame($requestData$payload->getRequestData());
        static::assertSame($recurring$payload->getRecurring());
        static::assertSame($source$payload->getSource());
    }
}
$transaction = new OrderTransactionEntity();
        $order = new OrderEntity();
        $returnUrl = 'https://foo.bar';
        $requestData = ['foo' => 'bar'];
        $recurring = new RecurringDataStruct('foo', new \DateTime());
        $source = new Source('foo', 'bar', '1.0.0');

        $payload = new AsyncPayPayload($transaction$order$returnUrl$requestData$recurring);
        $payload->setSource($source);

        static::assertEquals($transaction$payload->getOrderTransaction());
        static::assertSame($order$payload->getOrder());
        static::assertSame($returnUrl$payload->getReturnUrl());
        static::assertSame($requestData$payload->getRequestData());
        static::assertSame($recurring$payload->getRecurring());
        static::assertSame($source$payload->getSource());
    }
}
protected ?array $identifiers = null
    ) {
        parent::__construct();
    }

    public function match(RuleScope $scope): bool
    {
        if (!$scope instanceof FlowRuleScope) {
            return false;
        }

        return RuleComparison::uuids($this->extractTagIds($scope->getOrder())$this->identifiers, $this->operator);
    }

    public function getConstraints(): array
    {
        $constraints = [
            'operator' => RuleConstraints::uuidOperators(),
        ];

        if ($this->operator === self::OPERATOR_EMPTY) {
            return $constraints;
        }

        

        };

        static::assertInstanceOf(PaymentTransactionStructFactory::class$factory->getDecorated());

        $transaction = new OrderTransactionEntity();
        $order = new OrderEntity();

        $struct = $factory->sync($transaction$order);

        static::assertSame($transaction$struct->getOrderTransaction());
        static::assertSame($order$struct->getOrder());
    }

    public function testSync(): void
    {
        $factory = new PaymentTransactionStructFactory();

        $transaction = new OrderTransactionEntity();
        $order = new OrderEntity();

        $struct = $factory->sync($transaction$order);

        
return [
            'isSet' => RuleConstraints::bool(true),
        ];
    }

    public function match(RuleScope $scope): bool
    {
        if (!$scope instanceof FlowRuleScope) {
            return false;
        }

        if (!$deliveries = $scope->getOrder()->getDeliveries()) {
            return false;
        }

        $value = 0;
        foreach ($deliveries->getElements() as $delivery) {
            $value += \count(array_filter($delivery->getTrackingCodes()));
        }

        return $value > 0 === $this->isSet;
    }

    
// If the product is a product in the stock, we must change the stock size to the new ordered quantity             $quantityDiff = $oldQuantity - $newQuantity;

            $product->setInStock($product->getInStock() + $quantityDiff);
            $this->entityManager->persist($product);
        }
    }

    public function removeProductDetail(OrderDetail $detail): void
    {
        // Do not increase instock for canceled orders         if ($detail->getOrder() && $detail->getOrder()->getOrderStatus()->getId() === -1) {
            return;
        }

        $product = $this->getProductFromDetail($detail);
        if ($product) {
            $product->setInStock($product->getInStock() + $detail->getQuantity());
            $this->entityManager->persist($product);
        }
    }

    /** * Returns the product of the product position */
$update->execute([
                'id' => Uuid::fromHexToBytes($id),
                'count' => (int) $total,
                'customerCount' => json_encode($totals, \JSON_THROW_ON_ERROR),
            ]);
        }
    }

    public function orderPlaced(CheckoutOrderPlacedEvent $event): void
    {
        $lineItems = $event->getOrder()->getLineItems();
        $customer = $event->getOrder()->getOrderCustomer();

        if (!$lineItems || !$customer) {
            return;
        }

        $promotionIds = [];
        /** @var OrderLineItemEntity $lineItem */
        foreach ($lineItems as $lineItem) {
            if ($lineItem->getType() !== PromotionProcessor::LINE_ITEM_TYPE) {
                continue;
            }
Home | Imprint | This part of the site doesn't use cookies.