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

magento-2.1 checkout payment-methods
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
add a comment |
Magento 2 payment Checkout page keep showing loader. without showing any error on console or in terminal.

magento-2.1 checkout payment-methods
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Can you show your var/log/exception.log file?
– Illia Arefyev
Aug 30 '17 at 13:43
add a comment |
Magento 2 payment Checkout page keep showing loader. without showing any error on console or in terminal.

magento-2.1 checkout payment-methods
Magento 2 payment Checkout page keep showing loader. without showing any error on console or in terminal.

magento-2.1 checkout payment-methods
magento-2.1 checkout payment-methods
edited Aug 31 '17 at 5:31
sanjay chopra
asked Aug 30 '17 at 13:20
sanjay choprasanjay chopra
64
64
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
bumped to the homepage by Community♦ 6 mins ago
This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.
Can you show your var/log/exception.log file?
– Illia Arefyev
Aug 30 '17 at 13:43
add a comment |
Can you show your var/log/exception.log file?
– Illia Arefyev
Aug 30 '17 at 13:43
Can you show your var/log/exception.log file?
– Illia Arefyev
Aug 30 '17 at 13:43
Can you show your var/log/exception.log file?
– Illia Arefyev
Aug 30 '17 at 13:43
add a comment |
3 Answers
3
active
oldest
votes
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.
– 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
add a comment |
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.
add a comment |
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
MagentoQuoteModelCartTotals::setExtensionAttributes() must be an
instance of MagentoQuoteApiDataTotalsExtensionInterface, instance
of MagentoQuoteApiDataAddressExtension 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 MagentoQuoteModelCartCartTotalRepository
For that, add following in Namespace/Module/etc/di.xml
<preference for="MagentoQuoteModelCartCartTotalRepository" type="NamespaceModuleModelRewriteQuoteCartTotalRepository" />
- Create CartTotalRepository.php at the path NamespaceModuleModelRewriteQuoteCartTotalRepository.php
Paste the following code in CartTotalRepository.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace NamespaceModuleModelRewriteQuote;
use MagentoQuoteApi;
use MagentoQuoteApiCartRepositoryInterface;
use MagentoQuoteApiCartTotalRepositoryInterface;
use MagentoCatalogHelperProductConfigurationPool;
use MagentoFrameworkApiDataObjectHelper;
use MagentoQuoteModelCartTotalsItemConverter;
use MagentoQuoteApiCouponManagementInterface;
/*Added below two lines*/
use MagentoQuoteModelCartTotalsConverter;
use MagentoFrameworkApiExtensibleDataInterface;
/**
* Cart totals data object.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CartTotalRepository extends MagentoQuoteModelCartCartTotalRepository
{
/**
* Cart totals factory.
*
* @var ApiDataTotalsInterfaceFactory
*/
private $totalsFactory;
/**
* Quote repository.
*
* @var MagentoQuoteApiCartRepositoryInterface
*/
private $quoteRepository;
/**
* @var MagentoFrameworkApiDataObjectHelper
*/
private $dataObjectHelper;
/**
* @var ConfigurationPool
*/
private $itemConverter;
/**
* @var CouponManagementInterface
*/
protected $couponService;
/**
* @var TotalsConverter
*/
protected $totalsConverter;
/**
* @param ApiDataTotalsInterfaceFactory $totalsFactory
* @param CartRepositoryInterface $quoteRepository
* @param DataObjectHelper $dataObjectHelper
* @param CouponManagementInterface $couponService
* @param TotalsConverter $totalsConverter
* @param ItemConverter $converter
*/
public function __construct(
ApiDataTotalsInterfaceFactory $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 MagentoQuoteModelQuote $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 MagentoQuoteApiDataTotalsInterface $quoteTotals */
$quoteTotals = $this->totalsFactory->create();
$this->dataObjectHelper->populateWithArray(
$quoteTotals,
$addressTotalsData,
MagentoQuoteApiDataTotalsInterface::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.
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "479"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f191209%2fmagento-2-payment-checkout-page-keep-showing-loader%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
– 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
add a comment |
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.
– 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
add a comment |
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.
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.
answered Aug 31 '17 at 5:42
Pavan KumarPavan Kumar
3321211
3321211
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
add a comment |
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
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
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
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
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
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
No didn't get any issue after fresh install.
– sanjay chopra
Aug 31 '17 at 6:52
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
answered Aug 31 '17 at 5:45
SarfarajSarfaraj
387418
387418
add a comment |
add a comment |
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
MagentoQuoteModelCartTotals::setExtensionAttributes() must be an
instance of MagentoQuoteApiDataTotalsExtensionInterface, instance
of MagentoQuoteApiDataAddressExtension 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 MagentoQuoteModelCartCartTotalRepository
For that, add following in Namespace/Module/etc/di.xml
<preference for="MagentoQuoteModelCartCartTotalRepository" type="NamespaceModuleModelRewriteQuoteCartTotalRepository" />
- Create CartTotalRepository.php at the path NamespaceModuleModelRewriteQuoteCartTotalRepository.php
Paste the following code in CartTotalRepository.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace NamespaceModuleModelRewriteQuote;
use MagentoQuoteApi;
use MagentoQuoteApiCartRepositoryInterface;
use MagentoQuoteApiCartTotalRepositoryInterface;
use MagentoCatalogHelperProductConfigurationPool;
use MagentoFrameworkApiDataObjectHelper;
use MagentoQuoteModelCartTotalsItemConverter;
use MagentoQuoteApiCouponManagementInterface;
/*Added below two lines*/
use MagentoQuoteModelCartTotalsConverter;
use MagentoFrameworkApiExtensibleDataInterface;
/**
* Cart totals data object.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CartTotalRepository extends MagentoQuoteModelCartCartTotalRepository
{
/**
* Cart totals factory.
*
* @var ApiDataTotalsInterfaceFactory
*/
private $totalsFactory;
/**
* Quote repository.
*
* @var MagentoQuoteApiCartRepositoryInterface
*/
private $quoteRepository;
/**
* @var MagentoFrameworkApiDataObjectHelper
*/
private $dataObjectHelper;
/**
* @var ConfigurationPool
*/
private $itemConverter;
/**
* @var CouponManagementInterface
*/
protected $couponService;
/**
* @var TotalsConverter
*/
protected $totalsConverter;
/**
* @param ApiDataTotalsInterfaceFactory $totalsFactory
* @param CartRepositoryInterface $quoteRepository
* @param DataObjectHelper $dataObjectHelper
* @param CouponManagementInterface $couponService
* @param TotalsConverter $totalsConverter
* @param ItemConverter $converter
*/
public function __construct(
ApiDataTotalsInterfaceFactory $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 MagentoQuoteModelQuote $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 MagentoQuoteApiDataTotalsInterface $quoteTotals */
$quoteTotals = $this->totalsFactory->create();
$this->dataObjectHelper->populateWithArray(
$quoteTotals,
$addressTotalsData,
MagentoQuoteApiDataTotalsInterface::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.
add a comment |
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
MagentoQuoteModelCartTotals::setExtensionAttributes() must be an
instance of MagentoQuoteApiDataTotalsExtensionInterface, instance
of MagentoQuoteApiDataAddressExtension 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 MagentoQuoteModelCartCartTotalRepository
For that, add following in Namespace/Module/etc/di.xml
<preference for="MagentoQuoteModelCartCartTotalRepository" type="NamespaceModuleModelRewriteQuoteCartTotalRepository" />
- Create CartTotalRepository.php at the path NamespaceModuleModelRewriteQuoteCartTotalRepository.php
Paste the following code in CartTotalRepository.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace NamespaceModuleModelRewriteQuote;
use MagentoQuoteApi;
use MagentoQuoteApiCartRepositoryInterface;
use MagentoQuoteApiCartTotalRepositoryInterface;
use MagentoCatalogHelperProductConfigurationPool;
use MagentoFrameworkApiDataObjectHelper;
use MagentoQuoteModelCartTotalsItemConverter;
use MagentoQuoteApiCouponManagementInterface;
/*Added below two lines*/
use MagentoQuoteModelCartTotalsConverter;
use MagentoFrameworkApiExtensibleDataInterface;
/**
* Cart totals data object.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CartTotalRepository extends MagentoQuoteModelCartCartTotalRepository
{
/**
* Cart totals factory.
*
* @var ApiDataTotalsInterfaceFactory
*/
private $totalsFactory;
/**
* Quote repository.
*
* @var MagentoQuoteApiCartRepositoryInterface
*/
private $quoteRepository;
/**
* @var MagentoFrameworkApiDataObjectHelper
*/
private $dataObjectHelper;
/**
* @var ConfigurationPool
*/
private $itemConverter;
/**
* @var CouponManagementInterface
*/
protected $couponService;
/**
* @var TotalsConverter
*/
protected $totalsConverter;
/**
* @param ApiDataTotalsInterfaceFactory $totalsFactory
* @param CartRepositoryInterface $quoteRepository
* @param DataObjectHelper $dataObjectHelper
* @param CouponManagementInterface $couponService
* @param TotalsConverter $totalsConverter
* @param ItemConverter $converter
*/
public function __construct(
ApiDataTotalsInterfaceFactory $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 MagentoQuoteModelQuote $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 MagentoQuoteApiDataTotalsInterface $quoteTotals */
$quoteTotals = $this->totalsFactory->create();
$this->dataObjectHelper->populateWithArray(
$quoteTotals,
$addressTotalsData,
MagentoQuoteApiDataTotalsInterface::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.
add a comment |
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
MagentoQuoteModelCartTotals::setExtensionAttributes() must be an
instance of MagentoQuoteApiDataTotalsExtensionInterface, instance
of MagentoQuoteApiDataAddressExtension 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 MagentoQuoteModelCartCartTotalRepository
For that, add following in Namespace/Module/etc/di.xml
<preference for="MagentoQuoteModelCartCartTotalRepository" type="NamespaceModuleModelRewriteQuoteCartTotalRepository" />
- Create CartTotalRepository.php at the path NamespaceModuleModelRewriteQuoteCartTotalRepository.php
Paste the following code in CartTotalRepository.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace NamespaceModuleModelRewriteQuote;
use MagentoQuoteApi;
use MagentoQuoteApiCartRepositoryInterface;
use MagentoQuoteApiCartTotalRepositoryInterface;
use MagentoCatalogHelperProductConfigurationPool;
use MagentoFrameworkApiDataObjectHelper;
use MagentoQuoteModelCartTotalsItemConverter;
use MagentoQuoteApiCouponManagementInterface;
/*Added below two lines*/
use MagentoQuoteModelCartTotalsConverter;
use MagentoFrameworkApiExtensibleDataInterface;
/**
* Cart totals data object.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CartTotalRepository extends MagentoQuoteModelCartCartTotalRepository
{
/**
* Cart totals factory.
*
* @var ApiDataTotalsInterfaceFactory
*/
private $totalsFactory;
/**
* Quote repository.
*
* @var MagentoQuoteApiCartRepositoryInterface
*/
private $quoteRepository;
/**
* @var MagentoFrameworkApiDataObjectHelper
*/
private $dataObjectHelper;
/**
* @var ConfigurationPool
*/
private $itemConverter;
/**
* @var CouponManagementInterface
*/
protected $couponService;
/**
* @var TotalsConverter
*/
protected $totalsConverter;
/**
* @param ApiDataTotalsInterfaceFactory $totalsFactory
* @param CartRepositoryInterface $quoteRepository
* @param DataObjectHelper $dataObjectHelper
* @param CouponManagementInterface $couponService
* @param TotalsConverter $totalsConverter
* @param ItemConverter $converter
*/
public function __construct(
ApiDataTotalsInterfaceFactory $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 MagentoQuoteModelQuote $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 MagentoQuoteApiDataTotalsInterface $quoteTotals */
$quoteTotals = $this->totalsFactory->create();
$this->dataObjectHelper->populateWithArray(
$quoteTotals,
$addressTotalsData,
MagentoQuoteApiDataTotalsInterface::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.
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
MagentoQuoteModelCartTotals::setExtensionAttributes() must be an
instance of MagentoQuoteApiDataTotalsExtensionInterface, instance
of MagentoQuoteApiDataAddressExtension 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 MagentoQuoteModelCartCartTotalRepository
For that, add following in Namespace/Module/etc/di.xml
<preference for="MagentoQuoteModelCartCartTotalRepository" type="NamespaceModuleModelRewriteQuoteCartTotalRepository" />
- Create CartTotalRepository.php at the path NamespaceModuleModelRewriteQuoteCartTotalRepository.php
Paste the following code in CartTotalRepository.php
<?php
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace NamespaceModuleModelRewriteQuote;
use MagentoQuoteApi;
use MagentoQuoteApiCartRepositoryInterface;
use MagentoQuoteApiCartTotalRepositoryInterface;
use MagentoCatalogHelperProductConfigurationPool;
use MagentoFrameworkApiDataObjectHelper;
use MagentoQuoteModelCartTotalsItemConverter;
use MagentoQuoteApiCouponManagementInterface;
/*Added below two lines*/
use MagentoQuoteModelCartTotalsConverter;
use MagentoFrameworkApiExtensibleDataInterface;
/**
* Cart totals data object.
* @SuppressWarnings(PHPMD.CouplingBetweenObjects)
*/
class CartTotalRepository extends MagentoQuoteModelCartCartTotalRepository
{
/**
* Cart totals factory.
*
* @var ApiDataTotalsInterfaceFactory
*/
private $totalsFactory;
/**
* Quote repository.
*
* @var MagentoQuoteApiCartRepositoryInterface
*/
private $quoteRepository;
/**
* @var MagentoFrameworkApiDataObjectHelper
*/
private $dataObjectHelper;
/**
* @var ConfigurationPool
*/
private $itemConverter;
/**
* @var CouponManagementInterface
*/
protected $couponService;
/**
* @var TotalsConverter
*/
protected $totalsConverter;
/**
* @param ApiDataTotalsInterfaceFactory $totalsFactory
* @param CartRepositoryInterface $quoteRepository
* @param DataObjectHelper $dataObjectHelper
* @param CouponManagementInterface $couponService
* @param TotalsConverter $totalsConverter
* @param ItemConverter $converter
*/
public function __construct(
ApiDataTotalsInterfaceFactory $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 MagentoQuoteModelQuote $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 MagentoQuoteApiDataTotalsInterface $quoteTotals */
$quoteTotals = $this->totalsFactory->create();
$this->dataObjectHelper->populateWithArray(
$quoteTotals,
$addressTotalsData,
MagentoQuoteApiDataTotalsInterface::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.
edited Mar 19 '18 at 14:40
Rama Chandran M
2,71181530
2,71181530
answered Mar 19 '18 at 14:36
Kazim NooraniKazim Noorani
9671623
9671623
add a comment |
add a comment |
Thanks for contributing an answer to Magento Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f191209%2fmagento-2-payment-checkout-page-keep-showing-loader%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
var $window = $(window),
onScroll = function(e) {
var $elem = $('.new-login-left'),
docViewTop = $window.scrollTop(),
docViewBottom = docViewTop + $window.height(),
elemTop = $elem.offset().top,
elemBottom = elemTop + $elem.height();
if ((docViewTop elemBottom)) {
StackExchange.using('gps', function() { StackExchange.gps.track('embedded_signup_form.view', { location: 'question_page' }); });
$window.unbind('scroll', onScroll);
}
};
$window.on('scroll', onScroll);
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you show your var/log/exception.log file?
– Illia Arefyev
Aug 30 '17 at 13:43