Access Surcharge Information via Code
Our Surcharge extensions save their total information as an extension attribute. The below code shows how you would access the individual totals:
private function addFoomanTotals(\Magento\Sales\Api\Data\OrderInterface $order) { $extAttr = $order->getExtensionAttributes(); if (!$extAttr) { return; } $foomanGroup = $extAttr->getFoomanTotalGroup(); if (empty($foomanGroup)) { return; } $totals = $foomanGroup->getItems(); if (empty($totals)) { return; } foreach ($totals as $total) { /** @var \Fooman\Totals\Api\Data\OrderTotalInterface $total */ $description = $total->getLabel(); $baseAmount = $total->getBaseAmount(); $baseTaxAmount = $total->getBaseTaxAmount(); $amount = $total->getAmount(); $taxAmount = $total->getTaxAmount(); $identifier = $total->getTypeId(); $qty = 1; /** @TODO do something with the total */ } }