1

Magento 2 payment Checkout page keep showing loader. without showing any error on console or in terminal.Checkout Page

enter image description here

  • Can you show your var/log/exception.log file? – Illia Arefyev Aug 30 '17 at 13:43
  • Did you check with default theme? – Shesh Feb 17 '19 at 6:02
0

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. enter image description here So for testing purpose, you can enable 'Cash on Delivery' option from admin panel. Flush the cache and then try again.

| improve this answer | |
  • Thanx for reply Pavan , But i have to reinstall the magento setup again to solve this mystery. – sanjay chopra Aug 31 '17 at 5:47
  • why do u need to reinstall?? i don tunderstand – Pavan Kumar Aug 31 '17 at 5:53
  • i don't understand the exact problem either that's why i have to. – sanjay chopra Aug 31 '17 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. – Pavan Kumar Aug 31 '17 at 6:10
  • No didn't get any issue after fresh install. – sanjay chopra Aug 31 '17 at 6:52
0

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.

| improve this answer | |
0

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.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.