Closed haydencarlson closed 7 years ago
Has anyone else had this issue?
BMUP
@haydencarlson yes grand total does not include shipping amount. checked in version 2.1.5
But it only does it on first load. If I reload the checkout it gets the right price
Is this a bug in CE 2.1.5
Bump...
Hi @haydencarlson
\Magento\Quote\Api\CartTotalRepositoryInterface
is supposed to be used to obtain totals.
CartTotalRepositoryInterface doesn't work. How to reproduce:
1) add 7 'Jupiter All-Weather Trainer' items from the default store (Magento ver. 2.4.2-p1).
2)
private $cartTotalsRepository;
public function __construct(
...
CartTotalRepositoryInterface $cartTotalsRepository,
...
)
{
...
$this->cartTotalsRepository = $cartTotalsRepository;
}
$objectManager = ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');
$quote = $cart->getQuote();
$quoteTotals = $this->cartTotalsRepository->get($quote->getId());
$totalAmount = $quoteTotals->getGrandTotal();
$totalAmount here is different in comparison with the order total on checkout page. It doesn't include the shipping amount. If checkout page is refreshed then $totalAmount becomes correct.
Can be solved by cache cleaning. At least it works locally.
$objectManager = ObjectManager::getInstance();
$cacheFrontendPool = $objectManager->create('Magento\Framework\App\Cache\Frontend\Pool');
foreach ($cacheFrontendPool as $cacheFrontend) {
$cacheFrontend->getBackend()->clean();
}
Preconditions
Magento 2.0, PHP 7.0.20-2, MySQL 5.7.18 Running Ubuntu
Steps to reproduce
This is in my ConfigProvider. I console.log checkoutConfig.payment.[my_gateway]
On the first load of the checkout when I get the grand total it does not include shipping cost. If I reload page or click go to checkout again I get the correct amount.
The totals are properly shown on the checkout page just not through the method renderer.
Expected result
Correct Grand total.