CheckoutConfirmPageLoadedHook example

class CheckoutPageLoadedHookTest extends TestCase
{
    /** * @return array<array<PageLoadedHook&CartAware>> */
    public static function dataProviderHooks(): array
    {
        $salesChannelContext = Generator::createSalesChannelContext();

        return [
            [new CheckoutCartPageLoadedHook((new CheckoutCartPage())->assign(['cart' => new Cart(Uuid::randomHex())])$salesChannelContext)],
            [new CheckoutConfirmPageLoadedHook((new CheckoutConfirmPage())->assign(['cart' => new Cart(Uuid::randomHex())])$salesChannelContext)],
            [new CheckoutInfoWidgetLoadedHook((new OffcanvasCartPage())->assign(['cart' => new Cart(Uuid::randomHex())])$salesChannelContext)],
            [new CheckoutOffcanvasWidgetLoadedHook((new OffcanvasCartPage())->assign(['cart' => new Cart(Uuid::randomHex())])$salesChannelContext)],
            [new CheckoutRegisterPageLoadedHook((new CheckoutRegisterPage())->assign(['cart' => new Cart(Uuid::randomHex())])$salesChannelContext)],
        ];
    }

    /** * @dataProvider dataProviderHooks */
    public function testNameRespectsCartSource(PageLoadedHook&CartAware $hook): void
    {
        
return $this->redirectToRoute('frontend.checkout.register.page');
        }

        if ($this->cartService->getCart($context->getToken()$context)->getLineItems()->count() === 0) {
            return $this->redirectToRoute('frontend.checkout.cart.page');
        }

        $page = $this->confirmPageLoader->load($request$context);
        $cart = $page->getCart();
        $cartErrors = $cart->getErrors();

        $this->hook(new CheckoutConfirmPageLoadedHook($page$context));

        $this->addCartErrors($cart);

        if (!$request->query->getBoolean(self::REDIRECTED_FROM_SAME_ROUTE) && $this->routeNeedsReload($cartErrors)) {
            $cartErrors->clear();

            // To prevent redirect loops add the identifier that the request already got redirected from the same origin             return $this->redirectToRoute(
                'frontend.checkout.confirm.page',
                [...$request->query->all(), ...[self::REDIRECTED_FROM_SAME_ROUTE => true]],
            );
        }
Home | Imprint | This part of the site doesn't use cookies.