Getting subtotal and grand total in Observer

hey everyone, i’m trying to save the price/subtotal/grandtotal in a custom log file after order is placed using checkout_onepage_controller_success_action

my observer file right now can only get the Product Price, how would i get the other 2 aswell?

<?php namespace CDigitalOrderLogObserver; use MagentoFrameworkEventObserverInterface; use MagentoFrameworkAppRequestDataPersistorInterface; use MagentoFrameworkAppObjectManager; use MagentoCaptchaObserverCaptchaStringResolver; class MyObserver implements ObserverInterface { public function execute(MagentoFrameworkEventObserver $observer) { $order = $observer->getEvent()->getOrder(); $writer = new Zend_Log_Writer_Stream(BP . '/var/log/order.log'); $logger = new Zend_Log(); $logger->addWriter($writer); foreach ($order->getAllItems() as $item) { $PPrice = number_format($item->getPrice(), 2); $logger->info(print_r("Product Price: " . $PPrice, true)); } return $this; } } 

submitted by /u/atherakber
[link] [comments]