Skip to content

Commit 0f95377

Browse files
committed
Remove referer redirect
1 parent fdecc9d commit 0f95377

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/Controller/AddToCartAction.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
use Sylius\Bundle\OrderBundle\Factory\AddToCartCommandFactoryInterface;
1919
use Sylius\Bundle\ResourceBundle\Controller\NewResourceFactoryInterface;
2020
use Sylius\Bundle\ResourceBundle\Controller\RequestConfigurationFactoryInterface;
21+
use Sylius\Component\Core\Model\OrderItemInterface;
2122
use Sylius\Component\Order\Context\CartContextInterface;
22-
use Sylius\Component\Order\Model\OrderItemInterface;
2323
use Sylius\Component\Order\Modifier\OrderItemQuantityModifierInterface;
2424
use Sylius\Component\Order\Modifier\OrderModifierInterface;
2525
use Sylius\Component\Resource\Factory\FactoryInterface;
@@ -68,7 +68,11 @@ public function __invoke(Request $request): Response
6868
$form = $form->handleRequest($request);
6969

7070
if ($form->isSubmitted() && !$form->isValid()) {
71-
return new RedirectResponse((string) $request->headers->get('referer'));
71+
$product = $orderItem->getVariant()->getProduct();
72+
73+
return new RedirectResponse(
74+
$this->router->generate('sylius_shop_product_show', ['slug' => $product->getSlug()])
75+
);
7276
}
7377

7478
/** @var AddToCartCommandInterface $addToCartCommand */

0 commit comments

Comments
 (0)