I am trying to develop a module that calculates the value of a parameter and shows it in a page. (I am 95% sure that I need the value that is shown by default in cart subtotal at the cart checkout) How can I obtain that value and calculate it in a controller? (How do I obtain the value of the tax, shipping order and the voucher discount, cart subtotal). Are there differences between where the parameters are saved in the database based on the extensions that the user had installed?

1 Answer 1


I do not recommend that you use object manager but this is how to get the cart sub total within your controller

$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$cart = $objectManager->get('\Magento\Checkout\Model\Cart'); 

// get quote items collection
$itemsCollection = $cart->getQuote()->getSubtotal();

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.