1

I am integrating the custom module of custom payment gateway. I need the cart total on the checkout page for the price conversion before the payment.

How can I get the Cart total in JS or in the custom controller? Thanks in advance.

1 Answer 1

1

Try this:

$objectManager = \Magento\Framework\App\ObjectManager::getInstance(); 
$cart = $objectManager->get('\Magento\Checkout\Model\Cart');    
$totalItems = $cart->getQuote()->getItemsCount(); 
$totalQuantity = $cart->getQuote()->getItemsQty();
$grandTotal = $cart->getQuote()->getGrandTotal();

Hope it works for you..!!

2
  • with this code, no need to add object manager, because I already defined OM in above code.
    – temper
    Commented Nov 11, 2019 at 8:16
  • Thanks, this function get the total. $grandTotal = $cart->getQuote()->getGrandTotal();
    – Garry
    Commented Nov 11, 2019 at 10:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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