Magento – Magento 2 order redirected to cart -> getLastSuccessQuoteId() returns false

cartcheckoutmagento2

I'm trying to place order in magento 2.1.7 but every-time I click the "place order" button, I get redirected to the cart page.

With debugging I found out, that in the class /vendor/magento/module-checkout/Model/Session/SuccessValidator.php, there is a method isValid. This method does the following:

public function isValid()
{
    if (!$this->checkoutSession->getLastSuccessQuoteId()) {
        return false;
    }

    if (!$this->checkoutSession->getLastQuoteId() || !$this->checkoutSession->getLastOrderId()) {
        return false;
    }
    return true;
}

The first of these checks, getLastSuccessQuoteId() returns false. Unfortunately, I somehow can't find that method, that's why I have no idea what it does or tries to do.

The quote is created in the database, I see it in the quote table.

Does anyone have an idea what's happening here?

Best Answer

Alright, found the answer! The problem is I had an override for the class magento/module-sales/Model/Order.php where I overrode the method formatPrice(). Looks like this override somewhere internally produced an error that wasn't caught anywhere, that's why there was an error.

If someone has a similar error, check your overrides of core checkout,sales and order classes.

Related Topic