blockOrder example



    /** * @throws CustomerNotLoggedInException * @throws DeliveryWithoutAddressException * @throws EmptyCartException * @throws InvalidCartException * @throws InconsistentCriteriaIdsException */
    public function persist(Cart $cart, SalesChannelContext $context): string
    {
        if ($cart->getErrors()->blockOrder()) {
            throw CartException::invalidCart($cart->getErrors());
        }

        if (!$context->getCustomer()) {
            throw CartException::customerNotLoggedIn();
        }
        if ($cart->getLineItems()->count() <= 0) {
            throw new EmptyCartException();
        }

        $order = $this->converter->convertToOrder($cart$contextnew OrderConversionContext());

        
/** * @param Error $error */
    public function add($error): void
    {
        $this->set($error->getId()$error);
    }

    public function blockOrder(): bool
    {
        foreach ($this->getIterator() as $error) {
            if ($error->blockOrder()) {
                return true;
            }
        }

        return false;
    }

    public function blockResubmit(): bool
    {
        foreach ($this->getIterator() as $error) {
            if ($error->blockResubmit()) {
                
if ($testSwitchToDefault) {
            $activeShippingMethod = $crawler->filterXPath('//div[contains(concat(" ",normalize-space(@class)," "), " shipping-method-radio ")][input/@checked]')->text();
            static::assertStringContainsString('Standard', $activeShippingMethod);

            $activePaymentMethod = $crawler->filterXPath('//div[contains(concat(" ",normalize-space(@class)," "), " payment-method-radio ")][input/@checked]')->text();
            static::assertStringContainsString('Paid in advance', $activePaymentMethod);
        }

        // Ensure submit order button is disabled         if (!$stockError) {
            $submitButton = $crawler->filterXPath('//button[@id="confirmFormSubmit"][@disabled]');
            static::assertCount(($orderShouldBeBlocked || $errors->blockOrder()) ? 1 : 0, $submitButton);
        }
    }

    /** * @return array<array<mixed>> */
    public static function errorDataProvider(): array
    {
        return [
            // One shipping method blocked is expected to be switched             [
                
abstract public function getId(): string;

    abstract public function getMessageKey(): string;

    abstract public function getLevel(): int;

    abstract public function blockOrder(): bool;

    public function blockResubmit(): bool
    {
        return $this->blockOrder();
    }

    /** * @return array<string, mixed> */
    abstract public function getParameters(): array;

    public function getRoute(): ?ErrorRoute
    {
        return null;
    }

    
Home | Imprint | This part of the site doesn't use cookies.