Magento 2 payment Checkout page keep showing loader. without showing any error on console or in terminal.
3 Answers
It's because none of the payment options will be enabled by default. You can enable with Stores->configuration-> Sales->Payment Methods-> Cash On Delivery Payment. So for testing purpose, you can enable 'Cash on Delivery' option from admin panel. Flush the cache and then try again.
-
Thanx for reply Pavan , But i have to reinstall the magento setup again to solve this mystery. Commented Aug 31, 2017 at 5:47
-
-
i don't understand the exact problem either that's why i have to. Commented Aug 31, 2017 at 5:57
-
This is the only problem. I had faced teh same. If u havent yet started the reinstallation, stop it and check on this once. Ofcourse, if you reinstall also you will face the same issue. Commented Aug 31, 2017 at 6:10
-
If you have made changes in checkout file like override in your custom theme
Magento_Checkout/layout/checkout_index_index.xml
or inside
Magento_Checkout/templates/..
then keep it revert back it will work.
-
-1 This is not a answer, basically, he needs the way to fix not a way to revert. Commented Mar 14, 2022 at 9:34
I'm not sure but I think this is the solution for this particular case.
First of all check in console. A error might appear like,
Uncaught TypeError: Argument 1 passed to Magento\Quote\Model\Cart\Totals::setExtensionAttributes() must be an instance of Magento\Quote\Api\Data\TotalsExtensionInterface, instance of Magento\Quote\Api\Data\AddressExtension given, called in /htdocs/magento2.2/vendor/magento/framework/Api/DataObjectHelper.php on line 125 and defined in /htdocs/magento2.2/vendor/magento/module-quote/Model/Cart/Totals.php:592
I debugged for quite a while and come the following solution.
- Need to override Magento\Quote\Model\Cart\CartTotalRepository
For that, add following in Namespace/Module/etc/di.xml
<preference for="Magento\Quote\Model\Cart\CartTotalRepository" type="Namespace\Module\Model\Rewrite\Quote\CartTotalRepository" />
- Create CartTotalRepository.php at the path Namespace\Module\Model\Rewrite\Quote\CartTotalRepository.php
Paste the following code in CartTotalRepository.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Namespace\Module\Model\Rewrite\Quote;
use Magento\Quote\Api;
use Magento\Quote\Api\CartRepositoryInterface;
use Magento\Quote\Api\CartTotalRepositoryInterface;
use Magento\Catalog\Helper\Product\ConfigurationPool;
use Magento\Framework\Api\DataObjectHelper;
use Magento\Quote\Model\Cart\Totals\ItemConverter;
use Magento\Quote\Api\CouponManagementInterface;
/*Added below two lines*/
use Magento\Quote\Model\Cart\TotalsConverter;
use Magento\Framework\Api\ExtensibleDataInterface;
/**
* Cart totals data object.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CartTotalRepository extends \Magento\Quote\Model\Cart\CartTotalRepository
{
/**
* Cart totals factory.
*
* @var Api\Data\TotalsInterfaceFactory
*/
private $totalsFactory;
/**
* Quote repository.
*
* @var \Magento\Quote\Api\CartRepositoryInterface
*/
private $quoteRepository;
/**
* @var \Magento\Framework\Api\DataObjectHelper
*/
private $dataObjectHelper;
/**
* @var ConfigurationPool
*/
private $itemConverter;
/**
* @var CouponManagementInterface
*/
protected $couponService;
/**
* @var TotalsConverter
*/
protected $totalsConverter;
/**
* @param Api\Data\TotalsInterfaceFactory $totalsFactory
* @param CartRepositoryInterface $quoteRepository
* @param DataObjectHelper $dataObjectHelper
* @param CouponManagementInterface $couponService
* @param TotalsConverter $totalsConverter
* @param ItemConverter $converter
*/
public function __construct(
Api\Data\TotalsInterfaceFactory $totalsFactory,
CartRepositoryInterface $quoteRepository,
DataObjectHelper $dataObjectHelper,
CouponManagementInterface $couponService,
TotalsConverter $totalsConverter,
ItemConverter $converter
) {
$this->totalsFactory = $totalsFactory;
$this->quoteRepository = $quoteRepository;
$this->dataObjectHelper = $dataObjectHelper;
$this->couponService = $couponService;
$this->totalsConverter = $totalsConverter;
$this->itemConverter = $converter;
}
/**
* {@inheritDoc}
*
* @param int $cartId The cart ID.
* @return Totals Quote totals data.
*/
public function get($cartId)
{
/** @var \Magento\Quote\Model\Quote $quote */
$quote = $this->quoteRepository->getActive($cartId);
if ($quote->isVirtual()) {
$addressTotalsData = $quote->getBillingAddress()->getData();
$addressTotals = $quote->getBillingAddress()->getTotals();
} else {
$addressTotalsData = $quote->getShippingAddress()->getData();
$addressTotals = $quote->getShippingAddress()->getTotals();
}
//Added New Line Here
unset($addressTotalsData[ExtensibleDataInterface::EXTENSION_ATTRIBUTES_KEY]);
/** @var \Magento\Quote\Api\Data\TotalsInterface $quoteTotals */
$quoteTotals = $this->totalsFactory->create();
$this->dataObjectHelper->populateWithArray(
$quoteTotals,
$addressTotalsData,
\Magento\Quote\Api\Data\TotalsInterface::class
);
$items = [];
foreach ($quote->getAllVisibleItems() as $index => $item) {
$items[$index] = $this->itemConverter->modelToDataObject($item);
}
$calculatedTotals = $this->totalsConverter->process($addressTotals);
$quoteTotals->setTotalSegments($calculatedTotals);
$amount = $quoteTotals->getGrandTotal() - $quoteTotals->getTaxAmount();
$amount = $amount > 0 ? $amount : 0;
$quoteTotals->setCouponCode($this->couponService->get($cartId));
$quoteTotals->setGrandTotal($amount);
$quoteTotals->setItems($items);
$quoteTotals->setItemsQty($quote->getItemsQty());
$quoteTotals->setBaseCurrencyCode($quote->getBaseCurrencyCode());
$quoteTotals->setQuoteCurrencyCode($quote->getQuoteCurrencyCode());
return $quoteTotals;
}
}
I have made 2 modifications in the file. 1. Simply added 2 lines on line number 17 & 18. 2. Added 1 line on line number 102.