When users go to /checkout, they will be redirected to /checkout/cart.
1. Go to domain.com/checkout --> it will redirect them to /checkout/cart because there is no product
2. Add any product
3. Go to domain.com/checkout
4. User will be redirect to /checkout/cart
When looking at the Network from Chrome, the /checkout page was served by disk cache and redirect to cart.
Magento 2.3.2
PHP 7.2
MySQL 5.7
Using Built-In Cache
Sorry to necro, did you ever come across a fix for this?
I am currently having the same problem except it is for mobile devices ONLY.
I can add a product, go the basket, click continue to checkout and the page will not reload, just load a blank themed checkout without redirecting.
Clicking on the continue to checkout button should go to /checkout/#shipping
Hello @tony_le3
Magento’s checkout flow checks specific conditions before allowing access to the /checkout page:
Empty Cart Check: If the cart is empty, Magento redirects users to /checkout/cart.
Session Validation: Magento validates the user’s session to ensure that the cart and customer session data are valid.
Frontend Caching: Your browser might cache the redirect response, causing subsequent visits to /checkout to bypass Magento logic and immediately redirect to /checkout/cart.
Customizations: If there are customizations or third-party modules modifying checkout behavior, they might introduce additional conditions for redirection.
How to Fix or Adjust the Behavior
Disable Browser Cache During Testing: Since the /checkout page might be cached in the browser, clear the cache or disable caching for accurate testing:
Debug the Magento Logic for Checkout Redirection
Magento’s checkout controller includes logic for redirection. To debug:
Open Magento\Checkout\Controller\Index\Index.php.
Locate the execute() method, which handles the request.
Cart validation:
if (!$this->checkoutSession->getQuote()->hasItems() || $this->checkoutSession->getQuote()->getHasError())
{ $this->logger->debug('Redirecting to cart: no items or quote error.');
$this->_redirect('checkout/cart'); return; }
Hope it helps !
If you find our reply helpful, please give us kudos.
A Leading Magento Development Agency That Delivers Powerful Results, Innovation, and Secure Digital Transformation.
WebDesk Solution Support Team
Get a Free Quote | | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Thank You,
WebDesk Solution Support Team
Get a Free Quote | Email | Adobe Commerce Partner | Hire Us | Call Us 877.536.3789
Location: 150 King St. W. Toronto, ON M5H 1J9
It is like the system is treating an empty cart scenario the same as a checkout attempt, even when there’s a product. Have you checked if there’s a caching issue or a misconfiguration in the redirect logic? Maybe clearing the cache or downlaod honista reviewing the conditions for the redirect could help.